Interface FrameSourceConfiguration

Configuration for the frame source (camera).

interface FrameSourceConfiguration {
    constraints?: MediaStreamConstraints;
    rememberCameraDeviceId?: boolean;
    resolution?: "hd" | "full-hd" | "auto";
}

Properties

constraints?: MediaStreamConstraints

Allow passing in exact constraints for camera device selection via getUserMedia. If set, will override the FrameSourceConfiguration.resolution property and any other camera-related properties.

Example

In the example below, a camera device is explicitly selected by ID. Audio is explicitly not requested (never used by STRICH) and an HD-like resolution preference is specified by range.

constraints: {
video: {
deviceId: {
exact: '2d122f8e0630b5a6a19c157f066e13e05115f12f7d4dfb29e5560b4acefe7308'
},
width: {min: 800, ideal: 1280, max: 1600},
height: {min: 600, ideal: 720, max: 900}
},
audio: false
}

Remarks

This is an advanced option, and should only be used if you are familiar with the Media Capture and Streams API and have to build your own camera selection workflow.

Default Value

undefined
rememberCameraDeviceId?: boolean

Remember the camera that was last used to successfully scan a code.

Remarks

When set to true, the frame source will remember the camera used for the last successful scan and attempt to use the same camera when re-initializing the frame source. The remembered camera is cleared when a device is selected explicitly through the camera selector.

The mechanism relies on the browser returning stable device IDs from calls to enumerateDevices and related APIs. For privacy reasons, browsers will occasionally rotate these device IDs to make them non-stable to prevent fingerprinting. Some browsers like Samsung Internet even change them on every page load. This is a best-effort mechanism.

Default Value

false
resolution?: "hd" | "full-hd" | "auto"

Video frame resolution.

Remarks

The default resolution is 720p, which is usually enough for good quality barcodes. You can try higher resolutions if you have very fine or degraded codes, at the expense of higher computational requirements.

Default Value

hd