/// <summary>
/// Retrieve all the points (x, y, z position in meters) from Kinect, row by row.
/// </summary>
/// <returns>All the points (x, y, z position in meters) from Kinect, row by row.</returns>
public MCvPoint3D32f[] RetrievePointCloudMap()
{
IntPtr img = CvInvoke.cvRetrieveFrame(Ptr, (int)OpenNIDataType.PointCloudMap);
if (img == IntPtr.Zero)
{
return(null);
}
if (FlipType != Emgu.CV.CvEnum.FLIP.NONE)
{
CvInvoke.cvFlip(img, img, FlipType);
}
MIplImage iplImage = (MIplImage)Marshal.PtrToStructure(img, typeof(MIplImage));
MCvPoint3D32f[] points = new MCvPoint3D32f[iplImage.width * iplImage.height];
GCHandle handle = GCHandle.Alloc(points, GCHandleType.Pinned);
using (Matrix <float> m = new Matrix <float>(iplImage.height, iplImage.width, handle.AddrOfPinnedObject()))
{
CvInvoke.cvCopy(img, m, IntPtr.Zero);
}
handle.Free();
return(points);
}