"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Weird texture2D allocation from webcam in Unity

Hi,

 

I'm using the video background texture to process this in OpenCV. But when I show this texture I get some incorrect pixels shown and the camera input is a bit moved.In the added image, you will see that around the webcam texture is disorted. This happens in Genymotion and android devices too.

 

I would expect that there is a incorrect textureFormat, so I looked at the generated GameObject with a TextureBufferCamera. It has a different texureformat, but that still doesn't work. 

 

private void CreateAndSetVideoTexture()
	{
		Debug.Log ("creating webcam texture");

		// Create texture of size 0 that will be updated in the plugin (we allocate buffers in native code)
#if UNITY_ANDROID
		mTexture = new Texture2D(0, 0, TextureFormat.ARGB32, false);
		 
#else
		mTexture = new Texture2D(0, 0, TextureFormat.RGB565, false);

#endif

		mTexture.filterMode = FilterMode.Bilinear;
		mTexture.wrapMode = TextureWrapMode.Clamp;
		
		QCARRenderer.VideoTextureInfo info = QCARRenderer.Instance.GetVideoTextureInfo();

		// Set the texture to render into:
		if (!QCARRenderer.Instance.SetVideoBackgroundTexture(mTexture,mTexture.GetNativeTextureID()))
		{
			Debug.Log("Failed to setVideoBackgroundTexture " + mTexture.GetNativeTextureID());
		}
		else
		{
			Debug.Log("Successfully setVideoBackgroundTexture " + +mTexture.GetNativeTextureID());


		}
	}

After that I draw the  texture on GUI:

 

GUI.DrawTexture(new Rect(0,0, width, height), mTexture);