private void InitTrackers(bool depthOn, bool colorOn, bool userOn, bool skeletonOn, bool handsOn, bool gesturesOn) { if (!NuitrackManager.Instance.nuitrackInitialized) { exceptionsLogger.AddEntry(NuitrackErrorSolver.CheckError(NuitrackManager.Instance.initException, false) + "\n\n\n" + NuitrackManager.Instance.initException.ToString()); } if (skelVisId == 0) { if (root) { root.SetActive(true); } skelVis.SetActive(true); } if (skelVisId == 1) { indirectAvatar.SetActive(skeletonOn); } if (skelVisId == 2) { directAvatar.SetActive(skeletonOn); } if (skelVisId == 3) { indirectAvatarMan.SetActive(skeletonOn); } if (skelVisId == 4) { directAvatarMan.SetActive(skeletonOn); } NuitrackManager.Instance.ChangeModulesState(skeletonOn, handsOn, depthOn, colorOn, gesturesOn, userOn); }
void Update() { #if UNITY_ANDROID && !UNITY_EDITOR if (IsNuitrackLibrariesInitialized()) #endif if (nuitrackError) { return; } if (!pauseState || (asyncInit && _threadRunning)) { try { Users.UpdateData(skeletonData, handTrackerData, gestureData, NuitrackJson); if (gestureData != null) { gestureData.Dispose(); gestureData = null; } nuitrack.Nuitrack.Update(); } catch (System.Exception ex) { NuitrackErrorSolver.CheckError(ex, true, false); if (ex.ToString().Contains("LicenseNotAcquiredException")) { nuitrackError = true; } } } }
void Update() { try { string processingTimesInfo = ""; if ((NuitrackManager.UserTracker != null) && (NuitrackManager.UserTracker.GetProcessingTime() > 1f)) { processingTimesInfo += "User FPS: " + (1000f / NuitrackManager.UserTracker.GetProcessingTime()).ToString("0") + "\n"; } if ((NuitrackManager.SkeletonTracker != null) && (NuitrackManager.SkeletonTracker.GetProcessingTime() > 1f)) { processingTimesInfo += "Skeleton FPS: " + (1000f / NuitrackManager.SkeletonTracker.GetProcessingTime()).ToString("0") + "\n"; } if ((NuitrackManager.HandTracker != null) && (NuitrackManager.HandTracker.GetProcessingTime() > 1f)) { processingTimesInfo += "Hand FPS: " + (1000f / NuitrackManager.HandTracker.GetProcessingTime()).ToString("0") + "\n"; } perfomanceInfoText.text = processingTimesInfo; nuitrack.Nuitrack.Update(); } catch (Exception ex) { if (!licenseIsOver) { licenseIsOver = true; exceptionsLogger.AddEntry(NuitrackErrorSolver.CheckError(ex, false, false)); } } }
void Awake() { exceptionsLogger = GameObject.FindObjectOfType <ExceptionsLogger>(); NuitrackInitState state = NuitrackManager.Instance.InitState; if (state != NuitrackInitState.INIT_OK && Application.platform == RuntimePlatform.Android) { string error_message = "Nuitrack native libraries initialization error: " + Enum.GetName(typeof(NuitrackInitState), state); exceptionsLogger.AddEntry(NuitrackErrorSolver.CheckError(error_message)); } }
void NuitrackInit() { try { #if UNITY_EDITOR if (!NuitrackSDKEditor.ErrorSolver.TBBReplacer.Ready) { UnityEditor.EditorApplication.isPlaying = false; NuitrackSDKEditor.ErrorSolver.TBBReplacer.Start(); return; } #endif if (nuitrackInitialized) { return; } if (wifiConnect == WifiConnect.VicoVR) { nuitrack.Nuitrack.Init("", nuitrack.Nuitrack.NuitrackMode.DEBUG); nuitrack.Nuitrack.SetConfigValue("Settings.IPAddress", "192.168.1.1"); } else if (wifiConnect == WifiConnect.TVico) { Debug.Log("If something doesn't work, then read this (Wireless case section): github.com/3DiVi/nuitrack-sdk/blob/master/doc/TVico_User_Guide.md#wireless-case"); nuitrack.Nuitrack.Init("", nuitrack.Nuitrack.NuitrackMode.DEBUG); nuitrack.Nuitrack.SetConfigValue("Settings.IPAddress", "192.168.43.1"); } else { nuitrack.Nuitrack.Init(); if (useFileRecord && (Application.platform == RuntimePlatform.WindowsPlayer || Application.isEditor)) { string path = pathToFileRecord.Replace('\\', '/'); try { FileInfo fileInfo = new FileInfo(path); if (fileInfo.Exists && fileInfo.Extension != string.Empty) { if (fileInfo.Extension == ".oni") { nuitrack.Nuitrack.SetConfigValue("OpenNIModule.FileRecord", path); } else { nuitrack.Nuitrack.SetConfigValue("Realsense2Module.FileRecord", path); } } else { Debug.LogError(string.Format("Check the path to the recording file! File path: {0}", path)); } } catch (System.Exception) { Debug.LogError("File " + path + " Cannot be loaded!"); } } if (depth2ColorRegistration) { nuitrack.Nuitrack.SetConfigValue("DepthProvider.Depth2ColorRegistration", "true"); } if (useNuitrackAi) { if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.LinuxPlayer || Application.isEditor) { nuitrack.Nuitrack.SetConfigValue("DepthProvider.Depth2ColorRegistration", "true"); nuitrack.Nuitrack.SetConfigValue("Skeletonization.Type", "CNN_HPE"); } else { Debug.LogWarning("NuitrackAI doesn't support this platform: " + Application.platform + ". https://github.com/3DiVi/nuitrack-sdk/blob/master/doc/Nuitrack_AI.md"); } } if (useFaceTracking) { nuitrack.Nuitrack.SetConfigValue("DepthProvider.Depth2ColorRegistration", "true"); nuitrack.Nuitrack.SetConfigValue("Faces.ToUse", "true"); } if (mirror) { nuitrack.Nuitrack.SetConfigValue("DepthProvider.Mirror", "true"); } else { nuitrack.Nuitrack.SetConfigValue("DepthProvider.RotateAngle", ((int)sensorRotation).ToString()); } string devicesInfo = ""; if (nuitrack.Nuitrack.GetDeviceList().Count > 0) { for (int i = 0; i < nuitrack.Nuitrack.GetDeviceList().Count; i++) { nuitrack.device.NuitrackDevice device = nuitrack.Nuitrack.GetDeviceList()[i]; string sensorName = device.GetInfo(nuitrack.device.DeviceInfoType.DEVICE_NAME); if (i == 0) { LicenseInfo.Trial = device.GetActivationStatus() == nuitrack.device.ActivationStatus.TRIAL; LicenseInfo.SensorName = sensorName; } devicesInfo += "\nDevice " + i + " [Sensor Name: " + sensorName + ", License: " + device.GetActivationStatus() + "] "; } } //licenseInfo = JsonUtility.FromJson<LicenseInfo>(nuitrack.Nuitrack.GetDeviceList()); Debug.Log( "Nuitrack Start Info:\n" + "Skeletonization Type: " + nuitrack.Nuitrack.GetConfigValue("Skeletonization.Type") + "\n" + "Faces using: " + nuitrack.Nuitrack.GetConfigValue("Faces.ToUse") + devicesInfo); } nuitrack.Nuitrack.UpdateConfig(); Debug.Log("Nuitrack Init OK"); DepthSensor = nuitrack.DepthSensor.Create(); ColorSensor = nuitrack.ColorSensor.Create(); UserTracker = nuitrack.UserTracker.Create(); SkeletonTracker = nuitrack.SkeletonTracker.Create(); GestureRecognizer = nuitrack.GestureRecognizer.Create(); HandTracker = nuitrack.HandTracker.Create(); nuitrack.Nuitrack.Run(); Debug.Log("Nuitrack Run OK"); ChangeModulesState( skeletonTrackerModuleOn, handsTrackerModuleOn, depthModuleOn, colorModuleOn, gesturesRecognizerModuleOn, userTrackerModuleOn ); nuitrackInitialized = true; _threadRunning = false; } catch (System.Exception ex) { initException = ex; NuitrackErrorSolver.CheckError(ex); } }