Hello,
What are the best practices to stop & start the sensor interface in Unity with c#?
We would like to temporarily disable the sensor/tracking to save cpu/power.
We are using the latest NUI and latest Unity - with a real sense 435i on Windows 10
Hi On Data,
We stop and start the sensor only when the app is paused and resumed. For this purpose, we use OnDisable and OnEnable (Unity methods).
Hi Olga.
How would this work with a Unity app by sending a message using something like a web-socket.
If the Unity app is paused, would the Unity app still respond to external events? We want to be able to turn the sensor off & on at any time & the Unity app may still be in an active state.
What about using Nuitrack.Release? Nuitrack doesn’t have a function to pause, so we use release and start to stop tracking in for example menu’s
Thanks for the suggestions. We will have a look into them.
We have been trying out the suggestions; again, thanks for the help. Yes, we can stop the sensor but the restarting it is not working.
Our project is based on the face tracking example from NUITrack. We have tried calling methods in the NuitrackManager.cs like CloseUserGen(). But how do we restart the sensor? Obviously, there is the code in the Awake() method which is invoked when the scene is loaded… We made a new method Restart() based on the Awake code.
And code was added to the Canvas object that displays the video stream.
public void Stop()
{
NuitrackManager.onColorUpdate -= DrawColor;
}
public void Restart()
{
NuitrackManager.onColorUpdate += DrawColor;
}
Something is eluding us.
Nuitrack.Start(); should work.
We worked around the issue by loading different scenes. Our app is two scenes at the moment:
- a menu / start up scene
- main app scene
We are sending control messages to turn tracking on & off which results in a scene being loaded. It is fine for the moment. We may come back to it later.
Here’s an example. Insert the code below to Update
in NuitrackManager.cs
//Stop Nuitrack
if (Input.GetKeyDown(KeyCode.S))
{
ChangeModulsState(
false,
false,
false,
false,
false,
false
);
CloseUserGen();
}
//Start Nuitrack
if (Input.GetKeyDown(KeyCode.A))
{
ChangeModulsState(
skeletonTrackerModuleOn,
handsTrackerModuleOn,
depthModuleOn,
colorModuleOn,
gesturesRecognizerModuleOn,
userTrackerModuleOn
);
NuitrackInit();
}
But then if you update Nuitrack in the future, everything is just reset right?
If you mean that changes will be overwritten when using a new NuitrackSDK.unitypackage
, then the answer is ‘yes’. In the next release we’ll add methods to start and stop Nuitrack.
Don’t you already have those? We use Nuitrack.Init and Nuitrack.Release. Or is that not the same?
As far as we remember, you use a special version of NuitrackManager. If Nuitrack.Init
and Nuitrack.Release
work fine in your case, just keep using them. The new functions will be added for a ‘standard’ version of NuitrackManager.
Alright, just for the record, we also use the normal version. They don’t work fine since as soon as we release or init nuitrack we have a huge delay in the whole application. But they do what they’re supossed to do.
Hello, When I use these function in unity to stop nuitrack, unity crash. Please can you help me in this. Thanks
In new version of NuitrackSDK.unitypackage, in order to start \ stop nuitrack it is recommended to use the methods NuitrackManager.StartNuitrack and NuitrackManager.StopNuitrack
To avoid freezing the application while starting/stopping Nuitrack, check the box “Async Init” on NuitrackScripts prefab