This page concerns the Vuforia Engine API version 9.8 and earlier. It has been deprecated and will no longer be actively updated.
Accommodate performance-intensive augmented reality apps by setting the performance mode or managing the framerate. Adjusting these settings may result in video on see-through devices running smoother and cause less overheating due to processing and rendering loads.
If the device becomes too hot, the operating system may throttle the app to avoid overheating. Therefore, Vuforia allows you to dynamically adjust the framerate of your digital eyewear app in response to its runtime requirements. You can balance runtime performance against computational load and power consumption, giving you control of your app's performance characteristics.
The recommended framerate API is intended for use with video see-through eyewear devices, to adjust the framerate devices running augmented reality apps.
Optimization can be achieved in two ways in Unity and Native:
Performance Mode
When developing apps for Microsoft HoloLens or other video see-through devices there may be situations where the AR experience should last for a longer duration or you need to minimize Vuforia Engine impact on the CPU to allow your own algorithms more time. To limit the extent that the experience may be cut short by battery depletion or performance throttling, a performance mode can be set in the Vuforia Engine API and in the Unity inspector.
Enumerator |
|
---|---|
MODE_DEFAULT | Best compromise between speed and quality. |
MODE_OPTIMIZE_SPEED | Minimize Vuforia Engine impact on the system. |
MODE_OPTIMIZE_QUALITY | Optimize for Vuforia Engine performance. Application performance could go down. |
By default, MODE_DEFAULT
is used. Change the mode to MODE_OPTIMIZE_SPEED
if the Vuforia Engine performance in this mode meets your needs. If you expect the target to be moved continuously, we recommend using in the default mode.
Framerate Management
The Vuforia API provides the getRecommendedFps
and setTargetFps
methods to obtain and adjust to a recommended render framerate based on your app's rendering and performance requirements. To set a target framerate, call these methods when initializing the app.
The getRecommendedFPS
method accepts one or more hints as arguments. The following are the hint flags available for configuring the FPS recommendation:
Hint Flags |
Description |
FPSHINT_FAST | The fastest framerate available for the device and firmware combination. The application uses content that requires a high rendering rate, e.g. smooth character animation or a physics engine that requires frequent updates. |
FPSHINT_NO_VIDEOBACKGROUND | The application does not draw the video background (in optical see- through AR or if you have some non-AR/3D mode). Do not set this flag when in video see- through AR mode. |
FPSHINT_NONE | No hint is applied. |
FPSHINT_POWER_EFFICIENCY |
The application should be conservative in its power consumption, in order to reduce heat accumulation and increase battery life. On some devices this may come at the cost of reduced application performance and decreased quality of experience. |
FPSHINT_DEFAULT_FLAGS | Default flags used by Vuforia to determine FPS settings. |
Manage the maximum framerate on the video see-through device by using the below table for recommended settings for each device. Generally, rendering on the HoloLens always needs to be at 60 fps, while AR rendering on a mobile handheld device can be at 30 fps or at 60 fps, depending on the device.
NOTE: These are only recommended settings. For short AR experiences (less than 10 minutes), it's possible to render at 60 fps:
Eyewear/Mobile Device |
Target Render
|
Hints to use in
|
HoloLens | 60 | FAST |
Mobile Device | 30 | POWER_EFFICIENCY |
Mobile Device | 30 (60 on some iOS devices) |
NONE |
Mobile Device | 60 | FAST |
Setting Performance Mode and Framerate in Unity
Setting Performance Mode in Unity
The performance mode is found in Unity under Camera Device Mode in Vuforia Configuration in the Inspector Window of ARCamera GameObject. Locate the Camera Device Mode dropdown menu and select one of the three possible modes.
Setting the Framerate in Unity
The following code block queries Vuforia for the recommended frame rate and sets it using Unity’s Application.targetFrameRate API:
private void OnVuforiaStarted()
{
// Query Vuforia for recommended frame rate and set it in Unity
int targetFps = VuforiaRenderer.Instance.GetRecommendedFps(VuforiaRenderer.FpsHint.NONE);
// By default, we use Application.targetFrameRate to set the recommended frame rate.
// If developers use vsync in their quality settings, they should also set their
// QualitySettings.vSyncCount according to the value returned above.
// e.g: If targetFPS > 50 --> vSyncCount = 1; else vSyncCount = 2;
if (Application.targetFrameRate != targetFps)
{
Debug.Log("Setting frame rate to " + targetFps + "fps");
Application.targetFrameRate = targetFps;
}
}
Setting Performance Mode and Framerate in Native
Setting Performance Mode
Please refer to the following code examples to change the Camera Device Mode in native. Changing the mode should be done after Vuforia::CameraDevice::getInstance().init()
and before Vuforia::CameraDevice::getInstance().start()
.
// Select the default camera mode:
if (!Vuforia::CameraDevice::getInstance().selectVideoMode(
Vuforia::CameraDevice::MODE_DEFAULT))
return false;
or
// Select the default camera mode:
if (!Vuforia::CameraDevice::getInstance().selectVideoMode(
Vuforia::CameraDevice::MODE_OPTIMIZE_SPEED))
return false;
Setting the Framerate
Sets the recommended FPS to NONE unless running on an optical see-through device:
private boolean configureRenderingFrameRate()
{
// In this example we selected the default preset hint for best Mobile AR Experience
// See website documentation for more information on the rendering hint modes
// relevant to your AR experience.
int myRenderingOptions = Renderer.FPSHINT_FLAGS.FPSHINT_NONE;
// Retrieve recommended rendering frame rate best on currently configured/enabled vuforia features
// and selected application hint
int vuforiaRecommendedFPS = Renderer.getInstance().getRecommendedFps(myRenderingOptions);
// Use the recommended fps value computed by Vuforia
if (!Renderer.getInstance().setTargetFps(vuforiaRecommendedFPS))
{
Log.e(LOGTAG,"Failed to set rendering frame rate to: " + vuforiaRecommendedFPS + " fps");
return false;
}
else
{
Log.i(LOGTAG,"Configured frame rate set to recommended frame rate: " + vuforiaRecommendedFPS + " fps");
}
return true;
}