Search Unity

microsoft kinect SDK V1 version works on unity

Discussion in 'Works In Progress - Archive' started by ppb440219, May 4, 2012.

  1. ppb440219

    ppb440219

    Joined:
    May 4, 2012
    Posts:
    1
    Our group (NCU-VRH) wrote a dll file for unity, It can works on the microsoft kinect SDK V1 version.and we upload a sample file. Now we can get skeleton data and depth image, and we also calculate some assist and addition data that can use in game.

    To work the project, you need to install microsoft kinect SDK V1 and check does your computer have vc++2010 x86 redistribution package.

    But now we still faced a problem that is unity can't release the dll handle during we press Stop, so we can't simply Start it after just Stop, we need to close whole unity and open it again. Now we trying to solve it !

    If have any direction, please contact with us to getting better. :) (please in Chinese or English) ~
     

    Attached Files:

    Last edited: May 4, 2012
  2. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    If you look in the Kinect SDK Documentation there is a function

    void NuiShutdown()

    you will have to expose this method in your dll and call it in Unity when you want to shut down the Kinect
     
  3. fil

    fil

    Joined:
    Jul 17, 2012
    Posts:
    11
    will you make it to work with sdk v1.5?
     
  4. snaker

    snaker

    Joined:
    Feb 25, 2012
    Posts:
    11
    thanks for your share!
     
  5. dakka

    dakka

    Joined:
    Jun 25, 2010
    Posts:
    113
    I found a work around for this using SDK v1.0

    Trying to stop the Kinect by calling NuiShutdown caused the Unity Editor to freeze when you hit Play the second time, not sure if it was the shutdown or next init.

    Essentially only init the Kinect the first time you hit Play and stop the Kinect when you are not using the Unity Editor.

    Code (csharp):
    1.  
    2.     ...
    3.  
    4.     // Declare plugin function to initialize Kinect device
    5.     [DllImport(KINECT_PLUGIN)]
    6.     private static extern bool startKinect();
    7.  
    8.     // Check if we still running inside the Unity editor
    9.     // since multiple Kinect inits freeze Unity
    10.     [DllImport(KINECT_PLUGIN)]
    11.     private static extern bool isRunning();
    12.  
    13.     // Shutdown Kinect device
    14.     [DllImport (KINECT_PLUGIN)]
    15.     private static extern void stopKinect();
    16.  
    17.  
    18.     /*
    19.      * Initialize Kinect device during Application start
    20.      */
    21.     void Start ()
    22.     {
    23.         if (!isRunning())
    24.         {
    25.             Debug.Log("Kinect not running... will init");
    26.             kinectStarted = startKinect();
    27.         }
    28.         else
    29.         {
    30.             Debug.Log("Kinect already running...");
    31.             kinectStarted = true;
    32.         }
    33.     }
    34.  
    35.  
    36.     /*
    37.      * Shutdown Kinect device during Application Quit
    38.      */
    39.     void OnApplicationQuit()
    40.     {
    41.         if (kinectStarted  !Application.isEditor)
    42.         {
    43.             stopKinect();
    44.  
    45.             Debug.Log("Kinect stopped");
    46.         }
    47.         else
    48.         {
    49.             Debug.Log("Unity Editor: Kinect not stopped...");
    50.         }
    51.     }
    52.