2014-02-25 84 views
0

花了上個星期試圖讓我的C#程序顯示深度提要和RGB提要(類似於/Samples/Bin64/Release/NiViewer64.exe如何在窗口中顯示這兩個提要)。OpenNI show RGB camera feed

項目規格:C# - VS2013 Express OpenNI - 使用修改的 SimpleViewer.net(具有兩個深度的提要)。華碩Xtion Pro生活

我希望其中一個飼料成爲一個正常的攝像頭飼料,而不是深度飼料。

我猜它有事情做與此:

MapOutputMode mapMode = this.depth.MapOutputMode; 
this.bitmap = new Bitmap((int)mapMode.XRes, (int)mapMode.YRes,System.Drawing.Imaging.PixelFormat.Format24bppRgb); 

任何想法?

回答

0

最後想通了,謝謝另一位程序員。

  image = context.FindExistingNode(NodeType.Image) as ImageGenerator; 
      ImageMetaData imd = image.GetMetaData(); 


      lock (this) 
      { 
       //**************************************// 
       //***********RGB Camera Feed************// 
       //**************************************// 
       Rectangle rect = new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height); 
       BitmapData data = this.camera_feed.LockBits(rect, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); 

       byte* pDest = (byte*)data.Scan0.ToPointer(); 
       byte* imstp = (byte*)image.ImageMapPtr.ToPointer(); 

       // set pixels 
       for (int i = 0; i < imd.DataSize; i += 3, pDest += 3, imstp += 3) 
       { 
        pDest[0] = imstp[2]; 
        pDest[1] = imstp[1]; 
        pDest[2] = imstp[0]; 
       } 

,並宣佈這地方:

 public ImageGenerator image;