zoukankan      html  css  js  c++  java
  • untiy Kinect SDK 的默认BUG 修改方法

    Microsoft Kinect SDK Wrapper For Unity Crash Bug Fix

    May 10, 2012Dennis

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

    The first problem is that it is pointing to the wrong dll file. When you get this exception:

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

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

    C:\Windows\System32\Kinect10.dll

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

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

    This is 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 single call to SetDeviceStatusCallback() should fix the problem. To be 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 “catch (Exception e)”):

    NativeMethods.NuiSetDeviceStatusCallback(new NuiStatusProc());

    Now everything should run fine. If it doesn’t let me know :O

    解决问题

    1. 1.    找到KinectInterop.cs  改变其中的dll 文件的路径  改为:
    2. 2.   改完这里后只能运行一次 ,第二次运行的时候就会卡死
    C:\Windows\System32\Kinect10.dll

    找到 KinectInterop.cs 在其中添加空结构

    public struct NuiStatusProc
    {
    }
    1. 3.  然后在NativeMethods 方法中添加

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

            publicstaticexternvoidNuiSetDeviceStatusCallback(NuiStatusProccallback);

    4. KinectSensor.cs catch (Exception e)前加

    NativeMethods.NuiSetDeviceStatusCallback(new NuiStatusProc());
    至此  错误解决
     
    出自:http://www.rozengain.com/blog/2012/05/10/microsoft-kinect-sdk-wrapper-for-unity-crash-bug-fix/
     
     
    。net交流
  • 相关阅读:
    mysql用户授权及数据备份恢复
    mysql数据库导入导出 查询 修改表记录
    mysql数据库 索引 事务和事务回滚
    mysql数据库基本使用(增删改查)
    B-Tree 和 B+Tree
    网络七层模型及TCP、UDP,一次HTTP请求都发生了什么
    堆排、python实现堆排
    Linux 文件系统
    现有n 个乱序数,都大于 1000 ,让取排行榜前十,时间复杂度为o(n), top10, 或者 topK,应用场景榜单Top:10,堆实现Top k
    Ajax 基础
  • 原文地址:https://www.cnblogs.com/hcyblogs/p/4613264.html
Copyright © 2011-2022 走看看