Extracting real world coordinates in C#

Extracting real world coordinates in C#

I am trying to extract the real world coordinates using the senz3d in c#, would it be possible to supply some sample c# code in the best way of extracting this (preferably not c++ if possible) , I have managed to obtain PXCMImage of a depth frame but so far have failed to get the real world coordinates from this.

The closest I have got uses Marshal.Copy as shown below

        public List<point3D> copyDepthDataToList(PXCMImage image)
        {
            List<point3D> coordinates = new List<point3D>();

            int width = (int)image.imageInfo.width;

            int height = (int)image.imageInfo.height;

            PXCMImage.ImageData data;

            if (image.AcquireAccess(PXCMImage.Access.ACCESS_READ, out data) >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                short[] managedArray1 = new short[height * width * 3];

                IntPtr intPointer = data.buffer.planes[0];

                Marshal.Copy(intPointer, managedArray1, 0, (int)(height * width * 3));

                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        int idx = 3 * (j * width + i);
                        short x = managedArray1[idx];
                        short y = managedArray1[idx + 1];
                        short z = managedArray1[idx + 2];

                        if (z < 2000)
                        {
                            coordinates.Add(new point3D(x, y, z));
                        }
                    }
                }
            }
            return coordinates;
        }

 

Any help you could supply would be very much appreciated.

 

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.