AR Foundation Camera output to Render Texture?

If you subscribe to ARCameraManager.frameReceived event, then you can access these textures via ARCameraFrameEventArgs.textures.
To be sure which texture is TextureY and which one is TextureCbCr, I would not recommend accessing them by index, rather than find the index of property id and match it with the ARCameraFrameEventArgs.textures index. I think a code sample is better than a thousand of words :slight_smile:
Not optimized for performance, just to show an idea:

using UnityEngine;
using UnityEngine.XR.ARFoundation;


public class ARKitCameraTextures : MonoBehaviour {
    [SerializeField] ARCameraManager cameraManager = null;


    void Awake() {
        cameraManager.frameReceived += args => {
            var textureYPropId = Shader.PropertyToID("_textureY");
            var textureYPropIdIndex = args.propertyNameIds.IndexOf(textureYPropId);
            var textureY = args.textures[textureYPropIdIndex];

            var textureCbCrPropId = Shader.PropertyToID("_textureCbCr");
            var textureCbCrPropIdIndex = args.propertyNameIds.IndexOf(textureCbCrPropId);
            var textureCbCr = args.textures[textureCbCrPropIdIndex];
        };
    }
}
3 Likes