Table of Contents

Control the mega tracking process

This article describes how to control various functions and parameters in the Mega tracking process to meet the requirements of different application scenarios.

Before you start

Adjust device support level

The MegaTrackerFrameFilter.MinInputFrameLevel property of MegaTrackerFrameFilter is used to specify the minimum device level supported by Mega.

alt text

Mega can run on almost all types of frame data sources, but different frame data sources have different impacts on tracking performance.

By default, Mega selects the highest-level frame data source supported by the device for tracking. The session supporting Mega under default configuration has already configured frame data sources supporting 6DoF and 5DoF.

Two conditions must be met to support a certain level of frame data source during Mega operation:

For example, to support 3DoF tracking in the default session:

Another example, to remove 5DoF tracking support in the default session:

Session assembly will fail when no qualified frame data source is available.

Tracking target management

When using Mega, you need to specify the target (block) used by MegaTrackerFrameFilter.

Block source control

In most cases, it is recommended to maintain the default configuration, which is to import blocks using Mega Studio in the editor.

Select the Mega Tracker object under the session, and the Block Root Source option should remain as External (default).

alt text

At the same time, specify Block Root as the MegaBlocks object in the scene.

alt text

Modifying the Block Root Source option can specify other block source methods. For example, when importing data using ema, the Internal or Mixed options are usually selected.

In scripts, you can modify BlockHolder.BlockRootSource to achieve the same effect.

Multi-target tracking control

In most Mega usage scenarios, there is no need to use multiple targets. Before mastering how to prevent multiple blocks from interfering with each other, it is recommended to have only one block in a localization library.

Tip

In principle, Mega calculates the device's position in all blocks, rather than selecting blocks seen by the device from the localization library. Improper use may lead to performance degradation due to data confusion and other reasons.

Select the Mega Tracker object under the session, and modify the Multi Block option to enable or disable multi-target tracking.

alt text

In scripts, you can modify BlockHolder.MultiBlock to achieve the same effect.

Warning

Generally, only one block can exist simultaneously in a localization library.

Modifying multi-target configuration affects tracking performance and is generally not recommended. Please use it under the guidance of EasyAR technical support.

If this configuration has been modified during application execution, be sure to mention this when reporting issues to EasyAR.

Understand current system status

Under the default session configuration, UI messages will be displayed on the screen, including information about the Mega tracking status.

When localization is successful, the Mega Block will display Found status text along with the current tracked block name and ID:

alt text

When localization fails, the Mega Block will display NotFound status text:

alt text

Tip

NotFound is a normal state and frequently occurs throughout the Mega operation process. When this state appears, tracking is still ongoing. Usually, no special handling is required for the NotFound state in application development.

Using the MegaTrackerFrameFilter.LocalizationRespond event, you can obtain the current localization status to understand whether the system has found the tracking target.

The following code demonstrates how to use this event and common methods for handling abnormal states that require application attention:

private void Awake()
{
    megaTracker.LocalizationRespond += HandleLocalizationStatusChange;
}
        
private void HandleLocalizationStatusChange(MegaLocalizationResponse response)
{
    var status = response.Status;
    wakingUpCount = status == MegaTrackerLocalizationStatus.WakingUp ? wakingUpCount + 1 : 0;
    if (wakingUpCount >= 5)
    {
        // Service is waking up, need to have end users wait
    }

    if (status == MegaTrackerLocalizationStatus.QpsLimitExceeded)
    {
        // QPS limit exceeded, some end users may randomly experience localization failures (overall tracking quality degradation)
        // Generally need to pay to increase QPS limit to ensure tracking quality under current user volume
    }

    if (status == MegaTrackerLocalizationStatus.ApiTokenExpired)
    {
        // Token expired, this only occurs when using Token interface to access service
        // To resolve this, the app needs to request a Token from its backend and call MegaTrackerFrameFilter.UpdateToken to update
    }
}

If the application frequently encounters the MegaTrackerLocalizationStatus.RequestTimeout status, it usually indicates poor network conditions for the device connecting to the service. It is recommended to optimize the network environment to improve tracking quality. In scenarios where network conditions cannot be improved, consider increasing the request timeout.

Note

The pose returned by localization cannot be obtained through this event.

In fact, the pose returned by localization is not needed in application development. EasyAR will calculate a more accurate pose through local algorithms after localization returns and provide it to developers for use. This pose is already reflected in the block's transform. Refer to obtain session running results.

Pause and resume

Mega's tracking and localization functions can be paused and resumed separately.

Pause tracking

Set MegaTrackerFrameFilter.enabled to false to pause tracking.

By default, after tracking is paused, all content under block nodes will be hidden.

Pause localization

Set MegaTrackerFrameFilter.EnableLocalization to false to pause localization.

Warning

Pausing localization affects tracking performance and is generally not recommended. Please use it under the guidance of EasyAR technical support.

If localization has been paused during application execution, be sure to mention this when reporting issues to EasyAR.

Service and request control

You can control the behavior of requesting services by modifying parameters of the MegaTrackerFrameFilter component.

Request interval and timeout

Select the Mega Tracker object under the session, and modify the options under Request Time Parameters to adjust the service request interval and timeout duration.

alt text

In scripts, you can modify MegaTrackerFrameFilter.RequestTimeParameters to achieve the same effect.

Warning

Modifying the request interval affects tracking performance and is generally not recommended. Please use it under the guidance of EasyAR technical support.

If the request interval has been modified during application execution, be sure to mention this when reporting issues to EasyAR.

Switch localization library

Use MegaTrackerFrameFilter.SwitchEndPoint(ExplicitAddressAccessData, BlockRootController) to switch localization libraries at runtime. When using this interface, the camera feed and session will not be interrupted.