2012-02-13 40 views
0

画像を取り込んで手の姿勢を検出するための画像処理を行う外部C#dllを作成しました。 私は現在kinectデータを取得するためにZigFuユニティバインディングを使用しています。今私はKinectからC#dllにImage/Depthデータを渡したいと思います。続きUnity C#から外部C#dllに画像/デプスデータを渡す

コードの抽出物である:ユニティで

C#の

h1.detectHandPose(OpenNIContext.Instance.Depth.GetDepthMap().XRes,OpenNIContext.Instance.Depth.GetDepthMap().YRes); 
h1はC#のDLLの私のC#のDLLクラス

を、コードのinstaceある

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: A null reference or invalid value was found [GDI+ status: InvalidParameter] System.Drawing.GDIPlus.CheckStatus (Status status) System.Drawing.Bitmap..ctor (Int32 width, Int32 height, Int32 stride, PixelFormat format, 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() (at Assets/OpenNI/Scripts/OpenNIDepthmapViewer.cs:152)

何か助けていただければ幸いです。

おかげで、

クマー
+0

http://answers.unity3d.comを試しましたか?それには数時間かかることがありますが、そこではより良い回答が得られる可能性があります。 –

答えて

0

ビットマップ()コンストラクタでストライドパラメータが間違っている - BMPのようないくつかの形式が必要であるため、ストライドは、必要な画像の行が占めるバイト数(すべきことであるが、画素の各行DWORDで整列されたアドレスまたはその他の要件で開始)

関連する問題