static void PingNuitrack() { #if NUITRACK_PORTABLE if (!Directory.Exists(Application.dataPath + "/NuitrackSDK/Plugins")) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, ""); } #endif #if !NUITRACK_PORTABLE if (Directory.Exists(Application.dataPath + "/NuitrackSDK/Plugins")) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "NUITRACK_PORTABLE"); Debug.Log("Switched to nuitrack_portable"); } #endif try { nuitrack.Nuitrack.Init(); string nuitrackType = "Runtime"; if (PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone).Contains("NUITRACK_PORTABLE")) { nuitrackType = "Portable"; } string initSuccessMessage = "<color=green><b>Test Nuitrack (ver." + nuitrack.Nuitrack.GetVersion() + ") init was successful! (type: " + nuitrackType + ")</b></color>\n" + backendMessage; bool haveActiveLicense = false; bool deviceConnect = false; 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); nuitrack.device.ActivationStatus activationStatus = device.GetActivationStatus(); initSuccessMessage += "\nDevice " + i + " [Sensor Name: " + sensorName + ", License: " + activationStatus + "]"; if (activationStatus != nuitrack.device.ActivationStatus.NONE) { haveActiveLicense = true; } deviceConnect = true; } } else { initSuccessMessage += "\nSensor not connected"; } nuitrack.Nuitrack.Release(); Debug.Log(initSuccessMessage); //if (deviceConnect && !haveActiveLicense) // Activation.NuitrackActivationWizard.Open(false); } catch (System.Exception ex) { Debug.Log("<color=red><b>Test Nuitrack init failed!</b></color>\n" + "<color=red><b>It is recommended to test on AllModulesScene. (Start the scene and follow the on-screen instructions)</b></color>\n" + backendMessage); Debug.Log(ex.ToString()); } if (!File.Exists(filename)) { FileInfo fi = new FileInfo(filename); fi.Create(); UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation(); } }
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); } }