Log in or register to post comments

Rendering camera background into RenderTexture

December 21, 2010 - 9:22am #1


I want to render camera-video feed into RenderTarget. In order to achieve I tried:
1) Made a second camera with same settings as my main camera, except I set target render texture on it. It works fine for all objects but not for camera-video.
2) Tried setting RenderTexture on ARCamera itself, but that doesn't help either - the camera video is still rendered as if there was no render target set.

Could you tell me how to render it into RenderTarget?


Rendering camera background into RenderTexture

February 28, 2018 - 5:31pm #5

Apologies for bringing up this post almost a decade later, but I found an answer so that others who stumble across this don't have to spend hours searching. You can simply call

Texture curFrame = VuforiaRenderer.Instance.VideoBackgroundTexture;

Hope that helps someone!

Re: Rendering camera background into RenderTexture

December 22, 2010 - 2:28am #4

Semi answer to myself:

ReadPixels reads screen contents into Texture2D with camera feed successfully. The only problem that it reads all my UI too, so the control of what I get into that texture is a bit complicated...

Re: Rendering camera background into RenderTexture

December 21, 2010 - 2:36pm #3

Yes, that would be enough for me, because I don't really care about performance, because I don't really need it every frame.

On the other hand (speaking in general - not for my particular goal) I think it would be nice to have runtime access to smaller resolution video feed (like 16x16 pixels, or even average of whole picture), which could be used for lighting object in Unity scene. I think QCAR extension could be more open to users - I don't have problems writing my own plugins as long as it gives me more access. Why don't you release sources of QCAR extension? My guess is that there is nothing proprietary there...but I might be wrong.

Thanks for your help.

Re: Rendering camera background into RenderTexture

December 21, 2010 - 9:38am #2

This is probably not possible with the current version of the QCAR extension. The camera background is drawn in native code, and the Unity camera does not have access to the video texture itself. This allows the video background to work across a wide range of devices, and is faster than rendering the camera image in Unity.

Future versions of the extension might include a function call to native to get a bitmap of the camera image that matches the current frame. Would this be helpful for your task here?

- Kim

Log in or register to post comments