Kinect gives 30 color frames every second, and it’s in a byte[ ] array, right now i have to convert it to Color32, then use Texture2D.SetPixels32(colorData) and Texture2D.Apply() to display it in the scene.
this is extremely slow, because of the convertion and data copying. what may help?
It’s in this section of the code. Not sure if this is still 4.6 compatible.
void WriteImageToTexture(Texture2D tex)
{
// NOTE: This method only works when unity is rendering with OpenGL ("unity.exe -force-opengl"). This is *much* faster
// then Texture2D::SetPixels32 which we would have to use otherwise
// NOTE: The native texture id needs a +1 if we are rendering to GUI
if (openGl) {
//Gl.glBindTexture(Gl.GL_TEXTURE_2D, (null == target) ? tex.GetNativeTextureID() + 1 : tex.GetNativeTextureID());
//Gl.glTexSubImage2D(Gl.GL_TEXTURE_2D, 0, 0, 0, (int)inputSize.x, (int)inputSize.y, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, Image.ImageMapPtr);
GL.BindTexture(GL.TEXTURE_2D, (null == target) ? tex.GetNativeTextureID() + 1 : tex.GetNativeTextureID());
GL.TexSubImage2D(GL.TEXTURE_2D, 0, 0, 0, (int)inputSize.x, (int)inputSize.y, GL.RGB, GL.UNSIGNED_BYTE, Image.ImageMapPtr);
return;
}
....