noUser

noUser is an action which is activated when there in no user within the region captured by the sensors. The function is already built-in in Javascript for you. 

Let’s see a simple example to understand how it works!

In order to trigger this function from Javascript we are going to create a message called “msg” in the HTML code, this by default is set to show the text ‘Awaiting’ and will change when there is no user captured by the sensors.

NOTE: For this simple example the text will ONLY change the first time after leaving the active area, and will stay with the same message regardless of whether you stay or leave it. For a more comprehensive example see the tutorial Creating an Ubox Advance App. 

The text in blue shows the line added onto the HTML code:

HTML

<html>

<head>
</head>

<body>
     <h1 id="msg">Awaiting</h1>
  <canvas id="skeletonsCanvas" width="640" height="480"></canvas>


</body>

</html>

Now, within the noUser function on JAVASCRIPT we are going to add the line which calls “msg” created on the HTML code, and will shown on the screen the message “No User!” when there is no user captured by the sensors (as highlighted in the NOTE aforementioned, for this simple example only works the first time this scenario happens).

JAVASCRIPT (UBOX EVENTS Tab)

function noUser() {
  console.debug('No User :)');
  //sendToArduino('1');
  document.getElementById("msg").innerHTML = "No User!";
}

If you are not using the uboxPlayer on the PC with the Kinect sensor you can test it out on the web. For doing so, open the following link, right click on the mouse and select “New User” from the dropdown menu. It will change as mentioned.

No User App link