【问题标题】:Passing Image/Depth data from Unity C# to external C# dll将图像/深度数据从 Unity C# 传递到外部 C# dll
【发布时间】:2012-02-13 07:02:28
【问题描述】:

我编写了一个外部 C# dll,它接收图像并进行图像处理以检测手部姿势。 我目前正在使用 ZigFu 统一绑定来获取 kinect 数据。现在我想将图像/深度数据从 Kinect 传递到我的 C# dll。

以下是代码摘录:

Unity 中的 C#

h1.detectHandPose(OpenNIContext.Instance.Depth.GetDepthMap().XRes,OpenNIContext.Instance.Depth.GetDepthMap().YRes);

其中 h1 是我的 C# dll 类的实例

和 C# dll 中的代码

public int detectHandPose(IntPtr srcptr,Int32 w,Int32 h)
{
   int fingerNum = 0;

   Bitmap srcbmp = new Bitmap(w, h, 2,System.Drawing.Imaging.PixelFormat.Format16bppGrayScale, srcptr);

   ccDefects(srcbmp);

   return fingerNum;
}

public Image<Bgr, Byte> ccDefects(Bitmap b)
{
   //all image processing code for convexity defects    
}

但是我无法运行它并出现以下错误:

ArgumentException:找到空引用或无效值 [GDI+ 状态:InvalidParameter] System.Drawing.GDIPlus.CheckStatus(Status 状态)System.Drawing.Bitmap..ctor(Int32宽度,Int32高度,Int32 stride, PixelFormat 格式, IntPtr scan0) (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int,int,System.Drawing.Imaging.PixelFormat,intptr) handDetectionDLL.handDetection.detectHandPose (IntPtr srcptr, Int32 w, Int32 h) OpenNIDepthmapViewer.FixedUpdate () (在 Assets/OpenNI/Scripts/OpenNIDepthmapViewer.cs:152)

感谢任何帮助。

谢谢, 库马尔

【问题讨论】:

  • 你试过answers.unity3d.com 吗?这可能需要几个小时,但您可能会在那里得到更好的答案。

标签: c# unity3d kinect


【解决方案1】:

Bitmap() 构造函数中的 stride 参数是错误的 - stride 应该是图像中一行占用的字节数(因为某些格式(如 BMP)要求每一行像素都从一个 DWORD 对齐的地址或某个其他此类要求)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    相关资源
    最近更新 更多