Table of Contents

Add a group of frame data sources

An AR session can include multiple frame data source components, called a frame source group. During runtime, the session selects the most suitable frame data source from the group based on the current device and enabled AR features. This article explains how to use and manage a frame source group.

Before you begin

  • Understand the basic concepts, types, and runtime selection methods of frame data sources.

Frame data source groups with preset AR session

The session created with default configuration comes with a set of frame data sources, which is generally sufficient when using a single AR feature.

Different preset sessions contain different frame data sources.

The session created with the ARSessionFactory.ARSessionPreset.ImageTracking preset or the AR Session (Image Tracking Preset) menu has only a single frame data source:

alt text

The session created with the ARSessionFactory.ARSessionPreset.MegaBlock_MotionTracking_Inertial preset or the AR Session (Mega Block Default Preset) menu contains a scene hierarchy with multiple frame data source components:

alt text

If a preset is initially used to create a session in the scene, when adding other features during iteration, it is necessary to not only add the corresponding frame filter components but also add appropriate frame data source components as needed.

Important

After upgrading from version 4.7 or lower, you need to completely delete the session and recreate it through the menu or ARSessionFactory to use the preset frame data source groups.

Below are the default frame data source components for all preset AR feature configurations. Note that the order in the list matches the component order in the scene's frame data sources:

Preset Frame data source group
  1. CameraDeviceFrameSource
  1. XREALFrameSource
  2. AREngineFrameSource
  3. ARCoreFrameSource
  4. ARCoreARFoundationFrameSource
  5. ARKitFrameSource
  6. ARKitARFoundationFrameSource
  7. VisionOSARKitFrameSource
  8. MotionTrackerFrameSource
  1. XREALFrameSource
  2. AREngineFrameSource
  3. ARCoreFrameSource
  4. ARCoreARFoundationFrameSource
  5. ARKitFrameSource
  6. ARKitARFoundationFrameSource
  7. VisionOSARKitFrameSource
  8. MotionTrackerFrameSource
  9. EditorCameraDeviceFrameSource
  1. XREALFrameSource
  2. AREngineFrameSource
  3. ARCoreFrameSource
  4. ARCoreARFoundationFrameSource
  5. ARKitFrameSource
  6. ARKitARFoundationFrameSource
  7. VisionOSARKitFrameSource
  8. MotionTrackerFrameSource
  9. InertialCameraDeviceFrameSource
  10. EditorCameraDeviceFrameSource
  1. XREALFrameSource
  2. AREngineFrameSource
  3. ARCoreFrameSource
  4. ARCoreARFoundationFrameSource
  5. ARKitFrameSource
  6. ARKitARFoundationFrameSource
  7. VisionOSARKitFrameSource
  8. MotionTrackerFrameSource
  9. InertialCameraDeviceFrameSource
  10. ThreeDofCameraDeviceFrameSource
  11. EditorCameraDeviceFrameSource
  1. XREALFrameSource
  2. AREngineFrameSource
  3. ARCoreFrameSource
  4. ARCoreARFoundationFrameSource
  5. ARKitFrameSource
  6. ARKitARFoundationFrameSource
  7. VisionOSARKitFrameSource
  8. MotionTrackerFrameSource
  9. InertialCameraDeviceFrameSource
  10. ThreeDofCameraDeviceFrameSource
  11. CameraDeviceFrameSource
  1. XREALFrameSource
  2. AREngineFrameSource
  3. ARCoreFrameSource
  4. ARCoreARFoundationFrameSource
  5. ARKitFrameSource
  6. ARKitARFoundationFrameSource
  7. VisionOSARKitFrameSource
  8. MotionTrackerFrameSource
  9. CameraDeviceFrameSource
Note

The component ordering created with presets ensures the use of the optimal frame data source on all devices supported by built-in frame data sources.

Use the default frame data source configuration

When using default parameters, the frame data source configuration will automatically adjust based on the device and the AR features enabled at runtime.

If the frame data source parameters have been manually modified, when the AR features in the session change (for example, adding motion tracking to a session that originally only included image tracking), the frame data source parameters may need to be manually adjusted to meet the new feature requirements, so that all AR features can run with optimal performance.

Important

After upgrading from version 4.7 or earlier, you need to completely delete the session and recreate it through the menu or ARSessionFactory to use the correct default parameters.

Add frame source group

In the Hierarchy view, select AR Session (EasyAR) and right-click, then use the menu EasyAR Sense > [ AR feature ] > Frame Source : * to add a suitable frame source component for the feature. Alternatively, you can use the menu EasyAR Sense > Frame Source by Transform Type > * Dof > Frame Source : * to add the required frame source component.

In scripts, you can use ARSessionFactory.AddFrameSource<Source>(GameObject, bool) to add a frame source component.

For example, using the menu EasyAR Sense > Frame Source by Transform Type > 3 Dof Rot-Only > Frame Source : Three Dof Camera Device will add a ThreeDofCameraDeviceFrameSource to the currently selected session.

alt text

The corresponding script code is as follows:

ARSessionFactory.AddFrameSource<ThreeDofCameraDeviceFrameSource>(session);

Frame data source sorting

During the session assembly process, only one frame data source in the frame data source group will be selected and assembled into the session. The selection rule depends on the value of the AssembleOptions.FrameSourceSelection property. Under the default configuration, the final selected frame data source can be influenced by adjusting the order of the components in the frame data source group.

Generally, you can directly move the frame source objects in the Hierarchy view to sort them, as described in sorting objects in the scene.

In scripts, you can use Transform.SetSiblingIndex(int) to adjust the order of objects.

For example, to place the MotionTrackerFrameSource before other frame data sources, you can select the Motion Tracker object in the Hierarchy view and drag it to the top position.

The same effect can also be achieved with the following script code:

motionTrackerFrameSource.transform.SetSiblingIndex(0);

Additionally, there are some predefined sorting methods available. In the Hierarchy view, select AR Session (EasyAR), right-click, and use the menu EasyAR Sense > Utility > Sort Frame Source : * > * to sort specific frame data source components.

In scripts, you can use ARSessionFactory.SortFrameSource(GameObject, ARSessionFactory.FrameSourceSortMethod) to achieve the same effect.

For example, using the menu EasyAR Sense > Utility > Sort Frame Source : Motion Tracker > System SLAM will place the MotionTrackerFrameSource before ARCoreFrameSource, ARCoreARFoundationFrameSource, ARKitFrameSource, ARKitARFoundationFrameSource, and AREngineFrameSource.

alt text

The corresponding script code is as follows:

ARSessionFactory.SortFrameSource(session, new ARSessionFactory.FrameSourceSortMethod { MotionTracker = ARSessionFactory.FrameSourceSortMethod.MotionTrackerSortMethod.PreferEasyAR });

After the above sorting, the scene hierarchy becomes:

alt text