The Vuforia Engine Camera API provides access to a device's camera and enables control of the camera parameters. Use them to optimize camera functionality for certain platforms and changing environments.
NOTE: Vuforia Engine also offer an Advanced Camera API that is only available for certain license types and Android operated devices.
The camera is tied to the Vuforia Engine life cycle and is initialized and deinitialized with the engine. To learn more on the camera is used in your AR session, please see the Working with the Camera.
After starting Vuforia Engine, the camera parameters can be adjusted with the
CameraController. For example, you can adjust the video modes and focus modes of the device’s camera.
On most platforms, as long as Vuforia Engine has access to the camera, other apps on the device cannot access it. To release the camera and allow other applications to access it, you can use
In Unity, this is done automatically as soon as the application is paused.
When developing apps for certain devices, it is sensible to adjust the video mode in accordance with the device’s performance capabilities. With the camera video modes, you can optimize for quality but with more strain on the computational load. Or you can optimize for speed to minimize the impact Vuforia Engine puts on the device.
A _DEFAULT mode is used if nothing else is set.
The video modes of the camera are described in more detail in Device Performance Optimization.
Call get/set to get the active mode and configure it to a preferred mode.
vuCameraControllerGetActiveVideoMode(const VuController* controller, VuCameraVideoModePreset* cameraVideoModePreset); vuCameraControllerSetActiveVideoMode(VuController* controller, VuCameraVideoModePreset cameraVideoModePreset);
Control the camera focus mode to continuously autofocus the camera or you can choose to let the user focus the camera to a fixed point through a user interaction. Please note that some devices may not support all of the focus modes available.
If nothing else is set, the focus mode is set to _NORMAL.
The focus modes of the camera are described at Device Performance Optimization.
Set the focus mode at runtime:
vuCameraControllerGetFocusMode(const VuController* controller, VuCameraFocusMode* focusMode); vuCameraControllerSetFocusMode(VuController* controller, VuCameraFocusMode focusMode);
Enable or disable the flash in environments with changing or very low illuminance. It can greatly improve detection and tracking. Please note, that not all devices possess flash hardware in which case the call will fail.
Enable/disable flash mode if the device supports it:
vuCameraControllerGetFlashMode(const VuController* controller, VuBool* flashMode); vuCameraControllerSetFlashMode(VuController* controller, VuBool flashMode);
Get VuCameraFrame from the State
Firstly, check if the camera provides frames to the state. If
vuStateHasCameraFrame returns VU_TRUE, then you can get the camera frame from the state (needed for hitTesting for example) and other useful information such as timestamp, indexing, and list of images.
vuStateHasCameraFrame(const VuState *state); vuStateGetCameraFrame (const VuState *state, VuCameraFrame **cameraFrame);