Question

Have spent the last week trying to have my C# program show both the depth feed and the RGB feed (similar to how /Samples/Bin64/Release/NiViewer64.exe shows both feeds in a window).

Project specs: C# - VS2013 Express OpenNI - Using a modified SimpleViewer.net (has two feeds of depth). Asus Xtion Pro Live

I would like one of the feeds to become a normal camera feed instead of the depth feed.

I'm guessing it has something to do with this:

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

Any ideas?

Was it helpful?

Solution

Finally figured it out, thanks to another programmer.

            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];
                }

and declare this somewhere:

        public ImageGenerator image;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top