Quantcast
Channel: Questions in topic: "webcam"
Viewing all articles
Browse latest Browse all 256

Reading Native Surface Texture into Streaming Unity Texture [Android]?

$
0
0
I am trying to retrieve the camera preview image on Android and show it on a plane in Unity. In my native code I created the following function: SurfaceTexture surfaceTex; public void setUpVideoTexture(int texturePtr){ surfaceTex = new SurfaceTexture(texturePtr); surfaceTex.setOnFrameAvailableListener(this); Camera cam = Camera.open();//Alternatively I call this function on startup try { cam.setPreviewTexture(surfaceTex); cam.setPreviewCallback(this); cam.startPreview(); Log.d("Unity","Preview texture set up"); } catch (IOException e) { e.printStackTrace(); } } In Unity I call this function and pass the native texture pointer of the Unity texture: jo.Call("setUpVideoTexture", (int)renderer.material.mainTexture.GetNativeTexturePtr()); So now the camera preview image should be written into the Unity texture on every update. However, on updating the surface texture, I get the error message "Error binding external texture image". I also tried using a RenderTexture but although I don't get an error the texture stays black. Why doesn't this work? Is it not possible to use the streaming texture in combination with a native surface texture?

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>