I am using EmguCV and OpenNi in C# to retrieve the pointcloud from the Kinect. The code I am using is below:
IntPtr img = CvInvoke.cvRetrieveFrame(kCapture.Ptr, 1);
if (img != IntPtr.Zero)
{
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 m = new Matrix(iplImage.height, iplImage.width, handle.AddrOfPinnedObject()))
{
CvInvoke.cvCopy(img, m, IntPtr.Zero);
}
handle.Free();
}
I get an exception with the message "OpenCV: src.channels() == dst.channels()" when I am trying to perform the copy operation.