Using External Cameras with UWP

Sideload camera intrinsics from externally connected cameras into the Vuforia Engine camera stream on UWP devices.

Create a JSON file to specify your own camera parameters for an external camera that is connected to a UWP device. The external camera must be connected via USB and compatible with Media Foundation.

NOTE: This way of sideloading camera intrinsics is not supported for in-built back- or front cameras on the device.

Camera JSON Configuration

Vuforia Engine selects a camera by first prioritizing inbuilt back-camera, external camera, then front-facing camera, in that order. When an external camera is selected, Vuforia Engine determines which camera parameters should be applied, but these can be overwritten by sideloading camera intrinsics from a JSON file.

Sideload custom camera settings and intrinsics for external cameras by creating a JSON file with the name vuforia-camera.json, and with the following elements in a single object.

frameRate

Camera frame rate.

resolution

Camera image resolution.

focalLength

Focal length in x and y direction.

principalPoint

Principal point.

Distortion

(Optional)

Camera distortion parameters. Float array of up to 8 values. The number of values determines the distortion model:

  • 0 values (empty array): If no values are given, a linear model is adopted. No distortion.
  • 1 value: ARCTAN model with one parameter.
  • 2 values: 2 radial parameters, no tangential parameters.
  • 3 values: 3 radial parameters, no tangential parameters.
  • 4 values: 2 radial parameters, plus 2 tangential parameters.
  • 5 values: 3 radial parameters, plus 2 tangential parameters.
  • 6 values: 6 radial parameters (rational), no tangential parameters.
  • 8 values: 6 radial parameters (rational), plus 2 tangential parameters.

The values are in the following order (r = radial, t = tangential):
[r0, r1, t0, t1, r2, r3, r4, r5].

Add the array in the root of vuforia-camera.json:

[
  {
    "frameRate": 30,
    "resolution": {
      "width": 1920,
      "height": 1080
    },
    "focalLength": {
      "x": 1024,
      "y": 1024
    },
    "principalPoint": {
      "x": 960,
      "y": 540
    },
    "distortion": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  }
]

Place vuforia-camera.json in the directory C:\Users\USER\AppData\Local\Packages\APPLICATION\LocalState\vuforia-camera.json of your app.

If the framerate or resolution properties specified in the vuforia-camera.json file are not supported by the external camera device, Vuforia Engine will not start.

When starting Vuforia Engine, and with the external camera connected and recognized by the device, the vuforia-camera.json with camera intrinsics is automatically sideloaded.

See Troubleshooting for UWP in case your in-built camera is prioritized.

Can this page be better?
Share your feedback via our issue tracker