This page concerns the Vuforia Engine API version 9.8 and earlier. It has been deprecated and will no longer be actively updated.
Developers of external systems looking to take advantage of Vuforia Engine can write their own driver that provides data from external systems for Vuforia Engine to work with..
A driver is a native C/C++ dynamic library (.so or .dll file) that implements specific calls. During runtime, Vuforia Engine loads the library and uses it as a data source (e.g., device poses and image frames).
To get started, download the Native SDK package appropriate for your platform from the Developer Portal. We are mainly interested in the Driver.h file. This file defines several functions and classes which must be extended by the custom driver. For more information, refer to the comments in Driver.h file. The following diagram illustrates the high-level integration of custom drivers.
Supported Camera Frame Formats
Vuforia Engine requires data input from the Vuforia Driver in the following data formats.
- Frames from the camera must be in formats YUYV, NV12, or NV21.
- The 6DOF position of the camera for every frame that was captured and transmitted.
By fulfilling these, the driver you create can communicate with Vuforia Engine and the engine can interpret the data to accurately render augmentations in relation to targets and device movements. For more information on the Vuforia Driver integration, see our guide on Vuforia Support for Custom Devices using Vuforia Driver
Functions
vuforiaDriver_getAPIVersion()
– Returns a number containing the Driver Framework version that the library has been built against and conforms to. This constant is defined in Driver.h asVUFORIA_DRIVER_API_VERSION
vuforiaDriver_getLibraryVersion()
– Returns a string containing the version describing the library version. The driver developer selects a version value that is non-empty and generally under 50 characters long (e.g.,“AndroidUVC-1.0.0”
)vuforiaDriver_init()
– Constructs and returns an instance of the VuforiaDriver object which defines the custom driver. The memory and the lifetime of this object is owned by the library. Object is expected to remain valid untilvuforiaDriver_deinit()
is called.vuforiaDriver_deinit()
– Destructs the specified instance of the VuforiaDriver object.
VuforiaDriver Class
createExternalCamera()
– Constructs a new ExternalCamera object. The memory and lifetime of this object is owned by the library. Object should remain valid untildestroyExternalCamera()
is called.destroyExternalCamera()
– Destructs the specified instance of the ExternalCamera objectcreateExternalPositionalDeviceTracker()
- Constructs a new ExternalPositionalDeviceTracker object. The memory and lifetime of this object is owned by the library. Object should remain valid untildestroyExternalPositionDeviceTracker
is called.destroyExternalPositionalDeviceTracker()
- Destructs the specified instance of the ExternalPositonalDeviceTracker object.getCapabilities()
- Queries the driver for supported capability. The driver can support camera frames with corresponding device poses or camera frames only. There are two different capabilities supported by Vuforia Driver. Use Vuforia::Driver::Capability::CAMERA_IMAGE for camera only sequence. For camera and pose sequence, use (Vuforia::Driver::Capability::CAMERA_IMAGE | Vuforia::Driver::Capability::CAMERA_POSE)
ExternalCamera Class
open()
– Allows the Driver to allocate any resources needed. After callingopen()
the supported camera modes must be available.getNumSupportedCameraModes()
– Returns the number of supported camera modes.getSupportedCameraMode(index)
– Returns a specific supported camera mode by index.start(cameraMode, CameraCallback)
– Starts providing camera frames to the specified callback class for the specified cameraMode.stop()
– Stops producing new camera frames to the callback.close()
– Closes the camera and release any resources obtained fromopen()
The ExternalCamera class also provides access to the following information through various functions (e.g., gets/sets). For more information, refer to the comments in Driver.h:
- ExposureMode
- ExposureValue
- FocusMode
- FocusValue
CameraCallback Class
The driver provides camera frames to Vuforia Engine through a callback class. The driver pushes CameraFrame
structure to Vuforia Engine through the CameraCallback::onNewCameraFrame
function. Each CameraFrame
structure points to a buffer containing the actual frame data. Frame data also includes an accurate timestamp, exposure time and frame width/height. Along with the frame data, camera details must also be provided through the intrinsics parameter of type CameraIntrinsics
. For more details on the CameraIntrinsics
structure, refer to the External Camera Calibration article. The information provided by the CameraFrame
structure must be accurate to achieve optimal performance.
ExternalPositionalDeviceTracker Class
open()
– Allows the Driver to allocate any needed resources. After callingopen()
the supported positional device tracker is availablestart(PoseCallback)
– Start providing pose data to the specified callback classstop()
– Stop producing new pose data to the callbackclose()
– Close the positional device tracker and release any resources obtained fromopen()
PoseCallback Class
The driver provides pose data to Vuforia Engine through a callback class. The driver pushes Pose
structure to Vuforia Engine through the PoseCallback::onNewPose
function. Each Pose
structure includes pose data (e.g., an accurate timestamp and translation (vector) along x, y and z axes followed by a 3*3 rotation matrix for the pose). For a pose and camera frame to be associated together, the timestamp in Pose
and CameraFrame
structures should match exactly. Driver implementation should first feed pose and then the matching camera frame. Pose is optional and in such scenarios, driver implementation can just feed the camera frames.
Driver Lifetime
Vuforia Engine manages the lifetime of the driver by making function calls in the following order:
vuforiaDriver_init()
– Creates a new instance of the VuforiaDriver classVuforiaDriver::getCapabilities()
– Queries driver capability.VuforiaDriver::createExternalPositionalDeviceTracker()
– Called if driver capability includes Vuforia::Driver::Capability::CAMERA_POSE to create a new instance of the ExternalPositionalDeviceTracker class.ExternalPositionalDeviceTracker::open()
– Allocates any resources required by the external system. This call is made only if capability includes Vuforia::Driver::Capability::CAMERA_POSEVuforiaDriver::createExternalCamera()
– Called if driver capability includes Vuforia::Driver::Capability::CAMERA_IMAGE to create a new instance of the ExternalCamera class.ExternalCamera::open()
– Allocates any resources required by the external system. This call is made only if capability includes Vuforia::Driver::Capability::CAMERA_IMAGEExternalPositionalDeviceTracker::start()
– Signals the external system to start providingPose
structures through thePoseCallback
ExternalCamera::start()
– Signals the external system to start providingCameraFrame
structures through theCameraCallback
- Vuforia Engine now consumes
Pose
andCameraFrame
structures provided through thePoseCallback
andCameraCallback
, respectively. ExternalPositionalDeviceTracker::stop()
– Signals the external system to stop providing poseExternalPositionalDeviceTracker:close()
– Deallocates any resources that the external system was usingExternalCamera::stop()
– Signals the external system to stop providing camera framesExternalCamera:close()
– Deallocates any resources that the external system was usingVuforiaDriver:: destroyExternalPositionalDeviceTracker()
– Destructs the ExternalPositionalDeviceTracker instanceVuforiaDriver:: destroyExternalCamera()
– Destructs the ExternalCamera instancevuforiaDriver_deinit()
– Destructs the VuforiaDriver instance
Using a Driver in Vuforia Engine
After the driver is compiled, it may be shared with other developers who want to use the external system. To use a driver within Vuforia Engine, the application developer must make the following call:
Android |
|
UWP |
|
The setDriverLibrary();
call must be made before calling Vuforia::init();
To disable an active driver and return to using default Vuforia Engine data capture mechanisms, pass a zero-length string to setDriverLibrary()
:
Android |
|
UWP |
|