OpenNI Unity Toolkit Tutorials: Single skeleton using a model

Step 1: Creatingthe basic objects

1.Update the scene

OpenNI Unity Toolkit Tutorials: Single skeleton using a model_第1张图片


1.     Adding the basic objects, thefirst of which is the OpenNISettingsPrefab.

2.     Play the game: Press play andlook at the results. Nothing much is seen in the game window (only the depthand radar viewers) but various messages appearin the console.

InNIContext:Init(Logger (NIEventLogger))
InOpenNIContext.InitContext with logger=Logger (NIEventLogger) query=Query(NIQuery)
Creatingtype=Depth
InNIUserAndSkeleton:Init(Logger (NIEventLogger))
initializingwith context
Creatingtype=User

     注,特别重要,那些程序跑起来,kinect传感器灯不亮的,大都是因为这个原因: If any error messages appear,specifically exceptions or "contextinvalid" messages, this usually means that OpenNI framework, an OpenNIcompliant middleware (e.g. NITE) or the sensor drivers are either not installedor an old version of them is installed. In this situation itis best toreinstall them (see thereadme.rtf file andBeforeyou Start for more information).


2.Look at what the sensor sees in the Depth Viewer

The NIDepthViewer shows thedepth image in the upper right corner of the screen. We can configure theNIDepthViewer in a number of ways

OpenNI Unity Toolkit Tutorials: Single skeleton using a model_第2张图片

3.Find the users in the Radar Viewer


When a user is just detected,they are considered uncalibrated and are in the uncalibratedcolor (red by default). When they are selected they become calibratingwhich prepares them for tracking (orange by default) and after a short time become calibrated (yellow by default). Theybecome tracking (green by default) when theskeleton is actually tracked and the user controls the input.

Step 2: Add theskeleton and user selection

1.Add the skeleton model

The goal of this tutorial is tocontrol a model so the first step is to add a model to control. To do this,drag the ConstructionWorkerPrefab from the samples prefabs into the scene.

2.Add a User selection method


Defining the user selection is based on thecapabilities provided by the Playermanagement and user selection module. For the purpose of the firsttutorial, we will assume a simple user selection scheme: the user closest to the sensor is the player.

    Create a new,empty game object and rename it Player Manager. Drag the NIPlayerManagerCOMSelectionscript to it.

  • Set the number of player to 1 (we only have one skeleton to control).
  • retries at 0. This represents how many times to try to calibrate after failing. For our purposes, 0 is good enough as we can always move a bit to retry.
  • Leave Max distance as is (100000 is 100 meters). This is the distance we consider someone with no better info to be at.
  • Leave the Failure penalty at its default. This is the distance we move backward any user who failed to calibrate (unless they move) so we won't get locked on them.
  • Leave the Min change to retry at its default of 20 cm. This means that we delete the "failed" tag from a user which moved from than 20cm from the position in which they failed to calibrate.
  • Leave the Hysteresis at 10cm. This means that if someone is selected we consider them to be 10cm closer to avoid going back and forth between two users who are very close to each other.

3.Play the game

Press play and stand in front of the sensor, move around and see howthe skeleton mimics your movements.

 OpenNI Unity Toolkit Tutorials: Single skeleton using a model_第3张图片

Enjoy your victory, you have completed your first sample!

以上都是自己基于OpenNI Unity Toolkit - Beta   0.9.7文档组织,经过本人亲自试验总结得到;虽然是英文,只要用心都可以看懂。

未完,待续....

转自http://blog.csdn.net/tanmengwen/article/details/7980458


你可能感兴趣的:(OpenNI Unity Toolkit Tutorials: Single skeleton using a model)