我正在尝试在Mac OS X 10.8(Macbook Pro w / Retina Display,如果模型有所不同)的Mono运行时Xamarin Studio 4.0下运行freenect。我让OpenKinect使用默认的可执行文件,它可以让你测试你是否正确构建它。但是,当我在.dll中导入freenect时,它会失败并向我抛出异常。我从源项目中运行它,并在参考项目中弹出了这个错误:
System.DllNotFoundException:freenect at at(wrapper managed-to-native)freenect.KinectNative:freenect_init (intptr&,intptr)at freenect.KinectNative.InitializeContext() [0x00000] in /Users/philiprader/Documents/OpenKinect/libfreenect/wrappers/csharp/src/lib/KinectNative.cs:153 在freenect.KinectNative.get_Context()[0x00014]中 /Users/philiprader/Documents/OpenKinect/libfreenect/wrappers/csharp/src/lib/KinectNative.cs:67 在freenect.Kinect.GetDeviceCount()[0x00000]中 /Users/philiprader/Documents/OpenKinect/libfreenect/wrappers/csharp/src/lib/Kinect.cs:288 在freenect.Kinect.get_DeviceCount()[0x00000]中 /Users/philiprader/Documents/OpenKinect/libfreenect/wrappers/csharp/src/lib/Kinect.cs:180 在KinectConsoleTest.MainClass.Main(System.String [] args)[0x00000] in:0
它指向freenect框架源内部的行是:
int result = KinectNative.freenect_init(ref KinectNative.freenectContext, IntPtr.Zero);
我在我的控制台中使用的代码是C#的示例之一(我更改了一些与MonoMac一起使用的代码):
using System;
using freenect;
using System.Threading;
namespace KinectConsoleTest
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine("----------------------------------------");
Console.WriteLine("| Kinect.NET Wrapper Test |");
Console.WriteLine("----------------------------------------\n");
// Try to get number of devices connected
Console.WriteLine(" - Device Count: " + Kinect.DeviceCount);
// Do more tests if there are devices present
if(Kinect.DeviceCount > 0)
{
// Try to open a device
Kinect k = new Kinect(0);
Console.Write(" - Opening device 0...");
k.Open();
Console.WriteLine("Done.");
// Try to set LED colors
Console.WriteLine(" - LED Testing");
string[] colors = Enum.GetNames(typeof(LEDColor));
foreach(string color in colors)
{
var c = (LEDColor)Enum.Parse(typeof(LEDColor), color);
Console.WriteLine("\t - Setting LED to Color: " + color);
k.LED.Color = c;
Thread.Sleep(3000);
}
// Try to control motor
Console.WriteLine(" - Motor Testing");
Console.WriteLine("\t - Setting tilt to 1 (should face all the way up)");
k.Motor.Tilt = 1;
Thread.Sleep(3000);
Console.WriteLine("\t - Setting tilt to -1 (should face all the way down)");
k.Motor.Tilt = -1;
Thread.Sleep(3000);
Console.WriteLine("\t - Setting tilt to 0 (should be back level)");
k.Motor.Tilt = 0;
Thread.Sleep(3000);
// Close device
Console.Write(" - Closing device 0...");
k.Close();
Console.WriteLine("Done.");
}
// Shutdown the Kinect context
Kinect.Shutdown();
// Pause...
Console.ReadKey(true);
}
}
}
我能解决这个问题吗?我无法在Google或OpenKinect网站上的任何地方找到答案。