Point Cloud

Feb 20, 2012 at 1:55 AM

Can you please provide a sample of saving the depth data to a text file. Like the sample you had in the beta 2 version. For some reason all that code was removed in this new release.

Coordinator
Feb 20, 2012 at 3:03 AM

I don't believe the c4f kit ever had that even in the sample app.  can you get the b2 source code and provide what you were thinking about?

Feb 20, 2012 at 12:39 PM

In the previous version under ImageFrameExtensions.cs you had a function ToPintCloud that is the function I am looking for.

Thanks 

Mar 13, 2012 at 1:45 PM

here is the code I am looking for but for the last version of the kinect sdk. Any help will be appreciated.

 

       public static List<Vector> ToPointCloud(this ImageFrame image, Runtime nui, int maximumDepth)
        {
            if (image == null)
                throw new ArgumentNullException("image");

            var width = image.Image.Width;
            var height = image.Image.Height;
            var greyIndex = 0;

            var points = new List<Vector>();

            for (var y = 0; y < height; y++)
            {
                for (var x = 0; x < width; x++)
                {
                    short depth;
                    switch (image.Type)
                    {
                        case ImageType.DepthAndPlayerIndex:
                            depth = (short)((image.Image.Bits[greyIndex] >> 3) | (image.Image.Bits[greyIndex + 1] << 5));
                            if (depth <= maximumDepth)
                            {
                                points.Add(nui.SkeletonEngine.DepthImageToSkeleton(((float)x / image.Image.Width), ((float)y / image.Image.Height), (short)(depth << 3)));
                            }
                            break;
                        case ImageType.Depth: // depth comes back mirrored
                            depth = (short)((image.Image.Bits[greyIndex] | image.Image.Bits[greyIndex + 1] << 8));
                            if (depth <= maximumDepth)
                            {
                                points.Add(nui.SkeletonEngine.DepthImageToSkeleton(((float)(width - x - 1) / image.Image.Width), ((float)y / image.Image.Height), (short)(depth << 3)));
                            }
                            break;
                    }

                    greyIndex += 2;
                }
            }

            return points.Where(p => p.X != 0 || p.Y != 0 || p.Z != 0).ToList();
        }

 

 

Coordinator
Mar 14, 2012 at 7:26 PM

The code you're referencing was never part of our toolkit...perhaps it's something someone else added in a different project?

Mar 14, 2012 at 11:55 PM

Okay I apologize if that is the case,  can then someon please help me in the modification of this function for the new SDK, I still do not understand very well the bits reading part of the X,Y,Z

Thanks