Log in or register to post comments

Get camera frames with augmented content on Hololens

July 20, 2017 - 5:35am #1

I want to get the frames of Vuforia camera (Rendered content included, not just the background).

I've made a script for an application that should be available for Android and for Hololens. On Android (see below) it work without problems: I cann see backgroundCamera with augmented contents, but on Hololens it doesn't work well the same code. In fact, with the Hololens I can see the texture RawImageRT with only the interface and the rendered content, without the background camera (that I see in the Android app). I need help!

Note: I use as camera the LeftStereoCamera (child of ARCamera prefab).

 

Here is the script:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;

public class RenderTextureScript : MonoBehaviour

{

    public Camera camera;

    int resWidth;

    int resHeight;

    RenderTexture rt;

    //public RenderTexture rt;

    public RawImage RawImageRT;

    public RawImage RawImageRT_2;

    // Use this for initialization

    Texture2D screenShot;

    void Start()

    {

        resWidth = Screen.width;

        resHeight = Screen.height;

        rt = new RenderTexture(resWidth, resHeight, 24, RenderTextureFormat.ARGB32);

        camera.targetTexture = rt; //Create new renderTexture and assign to camera

        RawImageRT.texture = rt;

        RawImageRT_2.texture = rt;

        //screenShot  = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false); //Create new texture



    }

    // Update is called once per frame

    void Update()

    {

        camera.Render();

        RenderTexture.active = rt;

        //screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0); //Apply pixels from camera onto Texture2D

    }



}

Log in or register to post comments