Software Archive
Read-only legacy content
17061 Discussions

How to implement R200's Person Tracking on Unity?

Lucas_M_2
Beginner
496 Views

Hello guys!

I'm being unable to implement the new R200's Person Tracking funciton on Unity as it keeps crashing. I find a lack of documentation on this matter on the SDK, we sure have many great examples on how to work with the camera natively using Visual Studio and I have seen the videos made by Jacob Pennock on Intel's Youtube Channel and they are great! Too bad there were only a few videos, it would really really be helpful to see some more detailed code examples (on how to work with Unity functions like Start(), Update(), etc. I'm struggling a lot to make Unity work with my project and the new Person Tracking functionality, as I find it pretty hard even to start and get some input from the camera. I've read the documentation and still, can't seem to make it work properly with Unity. If any of you guys could shed a light on this matter for me, it would be really appreciated.

Thank you,
Lucas.

0 Kudos
3 Replies
Xusheng_L_Intel
Employee
496 Views

Since the Person Tracking is the new MW in latest R5 release, we did not have time to provide the Unity sample app. In the meanwhile, you can look at our C++ sample codes @C:\Program Files (x86)\Intel\RSSDK\sample\RF_PersonTracking. Please let us know if you have any question. Thanks!

0 Kudos
MartyG
Honored Contributor III
496 Views

I can't help with the R200 problem specifically as I only have an F200.  I can provide some general guidelines about functions though.  

1.  Start, Update, etc are not just Unity functions.  They are used in the languages JavaScript and C#.  So you can see examples of uses of these functions by searching for JavaScript and C# scripts, not just Unity ones.

2.  In JavaScript scripts, the format used to define a function is function NAMEOFSCRIPT, whilst in C# it is void NAMEOFSCRIPT.  So if I was using a Start function in Javascript, the line would be:

function Start()

and if it was C#, it would be:

void Start()

The two open and closed brackets - () - after the function name are very important as your script will likely not run without them.  So it's good to get into the habit of instinctively using them right from the beginning of learning programming.

3.  The different types of functions do different things.

Start makes your script a "fire once" script, in that it will run once when the program starts and then not run again.

Update makes your script run on an infinite loop until somehow stopped. 

LateUpdate scripts are processed once all of the Update scripts have completed running one cycle.

Awake is a fire-once function like Start but makes your script run first before scripts with Start are run.

OnTrigger and OnCollision functions make the code in your script run only when a Unity object enter, stays in or exits the "collision field" surrounding the object containing your script (OnTrigger) or simply collides with the collision field of your object (OnCollision).

If your project has mixed controls, such as camera and mouse, you can use OnMouseDown and OnMouseUp to trigger an event when the mouse button is clicked down (OnMouseDown) or released after being clicked down (OnMouseUp).

As well as the standard type of function names, you can also give a function any name you want - e.g function MyFunctionName();.  

These will typically be treated by Unity as fire-once scripts like Start and Awake.

4.  In Unity's "Inspector" panel, if you look at a script then you will see that it has a tick-mark beside its name, indicating that it is active.  you can make a script dormant by default when the program runs by removing this tick to leave the tick-box blank.  You can then activate and deactivate the script at will by sending an enable or disable signal to the script from another script file.

5.  You can mix different types of function together in a single script with multiple sections  For instance, you can begin the script with a Start() section, and everything you put under this block will run once.  This is a good place to create and define variables.

e.g

Start()  {

var time = 1;

var speed = 1;

}

It is very important to note that a function is opened and closed with a forward and backward facing squiggly bracket, which is next to the letter P on your keyboard and is different from the normal brackets on the top number row of the keyboard.  These brackets "open" and "close" your function's code.

Once you have used the } bracket to close your code block, you can start another function beneath it.  For example, we will add an Update function beneath the Start one.

Start()  {

var time = 1;

var speed = 1;

}

Update() {

YOUR UPDATE CODE HERE

}

Again we use the normal brackets after the function name, and the squiggly brackets to define the opening and closing points of that function's block of code.

When your program runs, it will run the code in the Start section first and then ignore it thereafter.  The code in the Update section, meanwhile, will ignore what is in the Start section and infinitely loop the running of the code inside the Update section until the script is somehow stopped.  If a function has opening and closing brackets, it is though the script code inside other functions does not exist.  The only external code a function will look at is code outside of function brackets - for example, a set of variable definition statements at the top of your script before the Start function begins.

var GameScore = 0;

var Clock = 0;

Start()  {

var time = 1;

var speed = 1;

}

Update() {

YOUR UPDATE CODE HERE

}

**********

Hope some of this information helps you, Lucas!

 

 

 

 

0 Kudos
Lucas_M_2
Beginner
496 Views

David,
Thank you for the information! You guys keep up the good work, I'll continue and try to apply the new Person Tracking capabilities on Unity without making Unity crash.

Marty,
Thank you for your time for writing this, I know about some of these informations already. But it is never enough to read again! What I meant from my first comment is that I'm kind of confused about where to instantiate the camera modules, init() and dispose() them correctly, you see, I'm currently trying to work with the new PersonTracking funciton on the scene given by the SDK as example, but I think I might be doing something wrong as the Intel drivers keep crashing on the code execution. As David mentioned, the given documentation is not that clear or specific about which kind of information the PersonTracking streams on Init, how to retrieve it.

0 Kudos
Reply