Skip to main content

Auki::Integration::ARFoundation::CameraTextureProvider

An abstract base class for providing camera texture frames to an external system, such as Manna, from ARFoundation. More...

Inherits from MonoBehaviour

Inherited by Auki.Integration.ARFoundation.CameraFrameProvider

Public Events

Name
Action< Texture >OnNewTextureReady()
This event is triggered whenever there is a new Texture ready for consumption.

Public Functions

Name
TextureGetLastFrameTexture()
Call this method to return the latest available Texture.
CameraTextureProviderGetOrCreateComponent()
This is a static method, which does the following things for you:

Protected Functions

Name
virtual voidAwake()
Initializes the CameraTextureProvider and sets the ARCameraManager reference.
virtual voidOnEnable()
Subscribes to the ARCameraManager's frameReceived event when the component is enabled.
virtual voidOnDisable()
Unsubscribes from the ARCameraManager's frameReceived event when the component is disabled.
virtual voidOnCameraFrameReceived(ARCameraFrameEventArgs args)
voidProcessFrame(ARCameraFrameEventArgs frameInfo)
Processes the ARCameraFrameEventArgs to generate a new frame texture.
TGetOrCreateComponent< T >()
This is a helper extension method, which does the following things for you:

Public Attributes

Name
ARCameraManagerArCameraManager
AR Camera Manager necessary to supply camera frames.
longTimerMs
The minimum amount of time that should pass between each provided texture (in Milliseconds). This effectively throttles the frame gathering from ARFoundation, dropping the frames in between. Default value is 0 = provide a new texture as soon as it is available.
CameraArCamera
Camera being used by ARCameraManager.

Detailed Description

class Auki::Integration::ARFoundation::CameraTextureProvider;

An abstract base class for providing camera texture frames to an external system, such as Manna, from ARFoundation.

This code shows how to quickly use CameraTextureProvider with Manna. Finds any existing CameraTextureProvider component in the scene or creates it next to ARCamera. Then it feeds textures to it whenever is ready. To pause/resume texture provisioning, you can simply disable/enable the component.

var textureProviderComp = CameraTextureProvider.GetOrCreateComponent();
textureProviderComp.TimerMs = 1000; // get a new texture minimum every 1 sec (the first texture is returned immediately)
textureProviderComp.OnNewTextureReady += texture => _manna.ProcessVideoFrame(..., ..., ...);

Public Events Documentation

event OnNewTextureReady

Action< Texture > OnNewTextureReady()

This event is triggered whenever there is a new Texture ready for consumption.

Public Functions Documentation

function GetLastFrameTexture

Texture GetLastFrameTexture()

Call this method to return the latest available Texture.

Return: The latest Texture. Returns null if no texture is yet available.

function GetOrCreateComponent

static CameraTextureProvider GetOrCreateComponent()

This is a static method, which does the following things for you:

Exceptions:

  • InvalidOperationException Throws in case there is 0 or more than 1 ARCameraManager in the scene.

Return: The CameraTextureProvider component added (or already present) on the ARCameraManager GameObject

  • finds the ARCameraManager in the scene and checks that at least one and only one is active
  • gets or creates the suggested CameraTextureProvider component on the ARCameraManager object
  • returns the created CameraTextureProvider You can then attach to CameraTextureProvider your instance of Manna, so frames will be automatically fed.

Protected Functions Documentation

function Awake

virtual void Awake()

Initializes the CameraTextureProvider and sets the ARCameraManager reference.

function OnEnable

virtual void OnEnable()

Subscribes to the ARCameraManager's frameReceived event when the component is enabled.

function OnDisable

virtual void OnDisable()

Unsubscribes from the ARCameraManager's frameReceived event when the component is disabled.

function OnCameraFrameReceived

virtual void OnCameraFrameReceived(
ARCameraFrameEventArgs args
)

function ProcessFrame

void ProcessFrame(
ARCameraFrameEventArgs frameInfo
)

Processes the ARCameraFrameEventArgs to generate a new frame texture.

Parameters:

  • frameInfo The ARCameraFrameEventArgs containing frame data.

function GetOrCreateComponent< T >

static T GetOrCreateComponent< T >()

This is a helper extension method, which does the following things for you:

Exceptions:

  • InvalidOperationException Throws in case there is 0 or more than 1 ARCameraManager in the scene.

Template Parameters:

  • T The implementation of CameraTextureProvider to use, responsible to feed frames to Manna from ARFoundation

Return: The CameraTextureProvider component added (or already present) on the ARCameraManager GameObject

  • finds the ARCameraManager in the scene and checks that at least one and only one is active
  • gets or creates the suggested CameraTextureProvider component on the ARCameraManager object You can decide which CameraTextureProvider implementation to use, inheriting from CameraTextureProviderBase.

Public Attributes Documentation

variable ArCameraManager

ARCameraManager ArCameraManager;

AR Camera Manager necessary to supply camera frames.

variable TimerMs

long TimerMs = 0;

The minimum amount of time that should pass between each provided texture (in Milliseconds). This effectively throttles the frame gathering from ARFoundation, dropping the frames in between. Default value is 0 = provide a new texture as soon as it is available.

variable ArCamera

Camera ArCamera;

Camera being used by ARCameraManager.