none
How to re-initialialise Kinect ? RRS feed

  • Question

  • Hi,

       I m developing an application using kinect. I m using the IDE Visual Studio 2010 Professional.I m developing using vc++.

    My application involves switching between pages for seletion process and at a point i initial the kinect and the live video is displayed.. I do some processing here and den I switch to another page.I then go back to the home page and this procedure is carried out several times.

    My question is that eveytime the kinect is initialised so a new instnce of the kinect is created for everytim I do the iteration.This results in shoot of CPU memory.

    I have deleted / released all the arrays and pointers I have used in my applciation.

    I have kept most of the variable as private to reduce the memeory usage.

    I have also called

    NuiSetDeviceStatusCallback(dummyDeviceStatusCallback, this);

    before I get the sensor count ,look at each Kinect sensor and then get the status of the sensor, and if connected, then I initialize the kinect.

    then I define the dummyDeviceStatusCallback as 

    static void CALLBACK dummyDeviceStatusCallback(HRESULT, const OLECHAR*, const OLECHAR*, void*)
            {
              
            }

    Also when the page, which is used to connect with the kinect,is closed or destoryed, I use

    NuiSetDeviceStatusCallback(nullptr, nullptr);

    I still have my problem of memory shoot up . Can anyone please help me out in solving this issue?

    Regards,

    Sandhya .

    Monday, April 22, 2013 10:26 AM

All replies

  • Without seeing your code, it's difficult to tell.

    First question: Do you need to reinitialize the Kinect sensor every time? Could you change your program so that you just initialize it once, and leave it initialized until your program exits? This would be the easiest solution.

    If that approach is not practical for some reason, then you should check that you are calling both NuiShutdown and Release on your INuiSensor pointer at the point where you close down the Kinect (prior to reinitializing it).


    John | Kinect for Windows development team

    • Proposed as answer by John Elsbree [MSFT] Monday, April 22, 2013 7:02 PM
    • Unproposed as answer by SandhyaBK Tuesday, April 23, 2013 5:10 AM
    Monday, April 22, 2013 7:02 PM
  • I have tried all that in my code.. But it doesnt seem to give a solution..I have made separate calls for releasing the sensor and NuiShutdown  for INuiSensor pointer .

    The memory shoot up stil prevails in the code ......


    Sandhya

    Tuesday, April 23, 2013 5:25 AM
  • As John said you don't need to reinitialize it every time you move from one page to another. What i did i crated a static variable to store my sensor from the first menu and the rest of the application will use the static sensor variable and the nice thing i used the sensorchooser to manage this nicely for me.  i recently wrote an article that does that 

    https://channel9.msdn.com/coding4fun/kinect/Push-to-Press-with-the-Kinect-for-Windows-SDK-17


    Vuyiswa Maseko

    Tuesday, April 23, 2013 6:58 PM