【问题标题】:OpenNI show RGB camera feedOpenNI 显示 RGB 摄像头馈送
【发布时间】:2014-03-27 03:54:13
【问题描述】:

上周我试图让我的 C# 程序同时显示深度提要和 RGB 提要(类似于 /Samples/Bin64/Release/NiViewer64.exe 在窗口中显示这两个提要)。

项目规范:C# - VS2013 Express OpenNI - 使用修改后的 SimpleViewer.net(有两个深度提要)。华硕 Xtion Pro Live

我希望其中一个提要成为普通的相机提要,而不是深度提要。

我猜这与此有关:

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

有什么想法吗?

【问题讨论】:

    标签: c# camera openni depth


    【解决方案1】:

    终于弄明白了,感谢另一个程序员。

                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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 2011-11-18
      • 2015-07-28
      • 1970-01-01
      相关资源
      最近更新 更多