void Awake() { //Position later gets updated every update tracking call positionInit = transform.localPosition; position = positionInit; isThreaded = multithreading; zedCamera = sl.ZEDCamera.GetInstance(); ZedSVOManager = GetComponent <SVOManager>(); if (ZedSVOManager != null) { //Create a camera if ((ZedSVOManager.read || ZedSVOManager.record) && ZedSVOManager.videoFile.Length == 0) { ZedSVOManager.record = false; ZedSVOManager.read = false; } if (ZedSVOManager.read) { ZedSVOManager.record = false; zedCamera.CreateCameraSVO(ZedSVOManager.videoFile); } else { zedCamera.CreateCameraLive(videoMode, FPS); } } else { zedCamera.CreateCameraLive(videoMode, FPS); } Debug.Log("ZED SDK Version " + sl.ZEDCamera.GetSDKVersion()); //Initialize the camera in performance mode, make minimum depth //be minDist meters to avoid inaccurate hand occlusions sl.ERROR_CODE e = zedCamera.Init(depthMode, minDist); if (e != sl.ERROR_CODE.SUCCESS) { throw new Exception("Initialization failed " + e.ToString()); } if (ZedSVOManager != null) { if (ZedSVOManager.record) { if (zedCamera.EnableRecording(ZedSVOManager.videoFile) != sl.ERROR_CODE.SUCCESS) { ZedSVOManager.record = false; } } } }
void Awake() { positionInit = transform.localPosition; rotationInit = transform.localRotation; position = positionInit; orientation = Quaternion.identity; isThreaded = multithreading; zedCamera = sl.ZEDCamera.GetInstance(); ZedSVOManager = GetComponent <SVOManager>(); if (ZedSVOManager != null) { //Create a camera if ((ZedSVOManager.read || ZedSVOManager.record) && ZedSVOManager.videoFile.Length == 0) { ZedSVOManager.record = false; ZedSVOManager.read = false; } if (ZedSVOManager.read) { ZedSVOManager.record = false; zedCamera.CreateCameraSVO(ZedSVOManager.videoFile); } else { zedCamera.CreateCameraLive(videoMode, FPS); } } else { zedCamera.CreateCameraLive(videoMode, FPS); } Debug.Log("ZED SDK Version " + sl.ZEDCamera.GetSDKVersion()); //Initialize the camera in performance mode. sl.ERROR_CODE e = zedCamera.Init(depthMode); if (e != sl.ERROR_CODE.SUCCESS) { throw new Exception("Initialization failed " + e.ToString()); } if (ZedSVOManager != null) { if (ZedSVOManager.record) { if (zedCamera.EnableRecording(ZedSVOManager.videoFile) != sl.ERROR_CODE.SUCCESS) { ZedSVOManager.record = false; } } } }
/// <summary> /// Init the SVO, and launch the thread to enable the tracking /// </summary> private void ZEDReady() { FPS = (int)zedCamera.GetRequestedCameraFPS(); if (enableTracking) { trackerThread = new Thread(EnableTrackingThreaded); trackerThread.Start(); } if (zedSVOManager != null) { if (zedSVOManager.record) { if (zedCamera.EnableRecording(zedSVOManager.videoFile, zedSVOManager.compressionMode) != sl.ERROR_CODE.SUCCESS) { zedSVOManager.record = false; } } if (zedSVOManager.read) { zedSVOManager.NumberFrameMax = zedCamera.GetSVONumberOfFrames(); } } if (enableTracking) { trackerThread.Join(); } if (isStereoRig && UnityEngine.XR.XRDevice.isPresent) { ZEDMixedRealityPlugin.Pose pose = ar.InitTrackingAR(); originPosition = pose.translation; originRotation = pose.rotation; zedRigRoot.localPosition = originPosition; zedRigRoot.localRotation = originRotation; if (!zedCamera.IsHmdCompatible && zedCamera.IsCameraReady) { Debug.LogWarning("WARNING : AR Passtrough with a ZED is not recommended. You may consider using the ZED-M, designed for that purpose"); } } else { originPosition = initialPosition; originRotation = initialRotation; } #if UNITY_EDITOR UnityEditor.EditorApplication.playmodeStateChanged = HandleOnPlayModeChanged; #endif }
/// <summary> /// Init the SVO, and launch the thread to enable the tracking /// </summary> private void ZEDReady() { if (enableTracking) { trackerThread = new Thread(EnableTrackingThreaded); trackerThread.Start(); } if (zedSVOManager != null) { if (zedSVOManager.record) { if (zedCamera.EnableRecording(zedSVOManager.videoFile, zedSVOManager.compressionMode) != sl.ERROR_CODE.SUCCESS) { zedSVOManager.record = false; } } if (zedSVOManager.read) { zedSVOManager.NumberFrameMax = zedCamera.GetSVONumberOfFrames(); } } if (enableTracking) { trackerThread.Join(); } if (isStereoRig && UnityEngine.XR.XRDevice.isPresent) { ZEDMixedRealityPlugin.Pose pose = ar.InitTrackingAR(); originPosition = pose.translation; originRotation = pose.rotation; zedRigRoot.localPosition = originPosition; zedRigRoot.localRotation = originRotation; } else { originPosition = initialPosition; originRotation = initialRotation; } AdjustZEDRigCameraPosition(); #if UNITY_EDITOR UnityEditor.EditorApplication.playmodeStateChanged = HandleOnPlayModeChanged; #endif }
/// <summary> /// Init the SVOManager /// </summary> /// <param name="zedCamera"></param> public void InitSVO(sl.ZEDCamera zedCamera) { if (record) { if (zedCamera.EnableRecording(videoFile, compressionMode) != sl.ERROR_CODE.SUCCESS) { record = false; } } if (read) { NumberFrameMax = zedCamera.GetSVONumberOfFrames(); } }
/// <summary> /// Changes the value of record if recording fails, and gets the length of a read SVO file. /// </summary> /// <param name="zedCamera">Reference to the Scene's ZEDCamera instance.</param> public void InitSVO(sl.ZEDCamera zedCamera) { if (record) { sl.ERROR_CODE svoerror = zedCamera.EnableRecording(videoFile, compressionMode); if (svoerror != sl.ERROR_CODE.SUCCESS) { record = false; } else if (svoerror == sl.ERROR_CODE.SVO_RECORDING_ERROR) { Debug.LogError("SVO recording failed. Check that there is enough space on the drive and that the " + "path provided is valid."); } } if (read) { NumberFrameMax = zedCamera.GetSVONumberOfFrames(); } }
void Awake() { position = new Vector3(0, 0.0f, 0); orientation = Quaternion.identity; zedCamera = sl.ZEDCamera.GetInstance(); ZedSVOManager = GetComponent <SVOManager>(); if (ZedSVOManager != null) { //Create a camera if ((ZedSVOManager.read || ZedSVOManager.record) && ZedSVOManager.videoFile.Length == 0) { ZedSVOManager.record = false; ZedSVOManager.read = false; } if (ZedSVOManager.read) { ZedSVOManager.record = false; zedCamera.CreateCameraSVO(ZedSVOManager.videoFile); } else { zedCamera.CreateCameraLive(resolution, 0.0f); } } else { zedCamera.CreateCameraLive(resolution, 0.0f); } Debug.Log("ZED SDK Version " + sl.ZEDCamera.GetSDKVersion()); //Initialize the camera in performance mode. sl.ERROR_CODE e = zedCamera.Init(sl.DEPTH_MODE.PERFORMANCE); if (e != sl.ERROR_CODE.SUCCESS) { throw new Exception("Initialization failed " + e.ToString()); } if (ZedSVOManager != null) { if (ZedSVOManager.record) { if (zedCamera.EnableRecording(ZedSVOManager.videoFile) != sl.ERROR_CODE.SUCCESS) { ZedSVOManager.record = false; } } } if (UnityEngine.VR.VRSettings.enabled) { headset = true; UnityEngine.VR.InputTracking.Recenter(); } else { headset = false; cameraHeadOffset.y = 0; cameraHeadOffset.z = 0; Debug.LogWarning("This script needs the VR to work correctly"); } }
void Awake() { isMoving = tracking; positionInit = transform.localPosition; rotationInit = transform.localRotation; position = positionInit; orientation = Quaternion.identity; isThreaded = multithreading; zedCamera = sl.ZEDCamera.GetInstance(); zedSVOManager = GetComponent <SVOManager>(); if (zedSVOManager != null) { //Create a camera if ((zedSVOManager.read || zedSVOManager.record) && zedSVOManager.videoFile.Length == 0) { zedSVOManager.record = false; zedSVOManager.read = false; } if (zedSVOManager.read) { zedSVOManager.record = false; zedCamera.CreateCameraSVO(zedSVOManager.videoFile); } else { zedCamera.CreateCameraLive(resolution, FPS); } } else { zedCamera.CreateCameraLive(resolution, FPS); } Debug.Log("ZED SDK Version " + sl.ZEDCamera.GetSDKVersion()); //Initialize the camera in performance mode. sl.ERROR_CODE e = zedCamera.Init(depthMode); if (e != sl.ERROR_CODE.SUCCESS) { throw new Exception("Initialization failed " + e.ToString()); } if (zedSVOManager != null) { if (zedSVOManager.record) { if (zedCamera.EnableRecording(zedSVOManager.videoFile) != sl.ERROR_CODE.SUCCESS) { zedSVOManager.record = false; } } if (zedSVOManager.read) { zedSVOManager.NumberFrameMax = zedCamera.GetSVONumberOfFrames(); } } Component[] cams = gameObject.transform.GetComponentsInChildren(typeof(Camera)); foreach (Camera cam in cams) { if (cam.stereoTargetEye == StereoTargetEyeMask.None) { cameraLeft = cam.transform; // cam.cullingMask &= ~(1 << sl.ZEDCamera.TagOneObject); } } }