OpenCV & Kinect - Texture2D to Mat?

I am trying to get an image from the Kinect and use it in OpenCV. I get the image I need from the Kinect manager like so:

kinIm = manager.GetUsersLblTex();

This works. I can set a material’s mainTexture property and see it. Then I try and make a new Mat using the image data:

kinMat = new Mat(kinIm.width, kinIm.height, CvType.CV_8UC4);

And then try to convert the texture to Mat - this fails and tells me the output Mat object has to be of the same size.

Utils.textureToMat(kinIm, kinMat);

I assume it’s the color setting but the docs say it has to 8UC1, 3 or 4 and all of them generate the same error.

Hints?

I also could use the depthMap, but that is like so:

ushort[ ] pixels = manager.GetRawDepthMap();

How to convert the array of ushorts to a texture or Mat? Both of Unity’s Texture2D methods that I thought might work - LoadImage and LoadRawTextureData take arrays of type byte…

confused.