Untiy The default bug modification method for the Kinect SDK

Source: Internet
Author: User

Microsoft Kinect SDK Wrapper for Unity Crash Bug Fix

May, 2012Dennis

There ' s a great free Kinect SDK wrapper available for Unity. It's free & open source But there is still a few problems getting it to run with the 1.0 SDK (as opposed to the beta) .

The first problem is the it's pointing to the wrong DLL file. When you get the This exception:

DllNotFoundException: C:\Program Files (x86)\Microsoft Research KinectSDK\MSRKINECTNUI.DLL

You should open the file KinectInterop.cs and changes all DLLs paths to:

C:\Windows\System32\Kinect10.dll

This'll fix all compiler errors and it should run without problems.

However, it'll only run once. When you run it the second time Unity would freeze and you'll have a to kill the process. Not very convenient.

This was caused by a bug in the Microsoft SDK. According to this page, the problem is:

If C++ code is executing NuiInitializa/NuiShutdown multiple times through
the application‘s lifetime, SetDeviceStatusCallback should be called once,
before invoking those calls.

So apparently a , setdevicestatuscallback () should fix the problem. To is able to call this method we need to add some code to the KinectInterop.cs file. First of all we need to add an empty struct:

public struct NuiStatusProc
{
}

Then we need to link the native method. In the NativeMethods class add:

[DllImportAttribute(@"C:\Windows\System32\Kinect10.dll", EntryPoint = "NuiSetDeviceStatusCallback")]
                   public static extern void NuiSetDeviceStatusCallback(NuiStatusProc callback);

Now open the file KinectSensor.cs and add this line to the Void Awake () method (just before the line "CA TCH (Exception E) "):

NativeMethods.NuiSetDeviceStatusCallback(new NuiStatusProc());

Now everything should run fine. If it doesn ' t let me know:o

Solve the problem

    1. 1. Locate the path where KinectInterop.cs changed the DLL file to:
    2. 2. After this, you can only run once, the second run will be stuck
C:\Windows\System32\Kinect10.dll

Find KinectInterop.cs in which to add an empty structure

public struct NuiStatusProc
{
}
    1. 3. Then add in the NativeMethods method

[DllImportAttribute(@ "C:\Windows\System32\Kinect10.dll", entrypoint= " Nuisetdevicestatuscallback ")]

publicstaticexternvoidnuisetdevicestatuscallback(nuistatusproccallback);

4. "catch (Exception e)" in KinectSensor.cs Front plus

NativeMethods.NuiSetDeviceStatusCallback(new NuiStatusProc());
至此错误解决
 
出自:http://www.rozengain.com/blog/2012/05/10/microsoft-kinect-sdk-wrapper-for-unity-crash-bug-fix/
 
 

Untiy The default bug modification method for the Kinect SDK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.