Capture a fingerprint
Capture one or more fingerprints with the contactless flow.
Prerequisites
- An initialised
SladeIDinstance. - A
<video>element. The defaultfacingMode: 'auto'opens the rear camera and falls back to the front camera on devices that have no rear. Pass a specificcameraDeviceId(fromCameraManager.enumerateCameras()) when you want the user to pick — see Handle multiple cameras.
Steps
- Build a step script — use
FingerprintSteps.rightHand()for slap-plus-thumb, or pass a custom array. - Create a
FingerprintCaptureSession. - Wire
'step_change','guidance', and'completed'. - Call
start().
Full example
import {
SladeID,
FingerprintSteps,
type CapturedFingerprint,
} from '@sladeid/slade-id-sdk';
const sdk = new SladeID({
middlewareUrl: 'https://id.example.com',
clientSecret: '<ClientSecret>',
});
const video = document.querySelector<HTMLVideoElement>('#camera')!;
const session = sdk.createFingerprintSession(video, {
captureSteps: FingerprintSteps.rightHand(),
qualityThreshold: 40,
qualityPolicy: 'all',
});
const captures: CapturedFingerprint[] = [];
session.on('step_change', ({ index, step }) => {
console.log(`step ${index + 1}: ${step.label}`);
});
session.on('captured', (fp) => {
captures.push(fp);
});
session.on('completed', async () => {
const result = await sdk.enrollFingerprint('subject-123', {
fingers: captures.flatMap((c) =>
c.perFinger.map((pf) => ({
position: pf.position,
imageBase64: c.imageBase64,
nfiq2Score: pf.nfiq2Score,
retryCount: 0,
}))
),
deviceInfo: captures[0].deviceInfo,
});
console.log('enrolled', result);
});
await session.start();qualityPolicy: 'all' requires every finger in a slap to clear qualityThreshold. Use 'any' for 1:1 verification where one clean print is enough.
Handle multiple cameras
When a device has more than one camera (an external USB webcam, a virtual camera, an iPad with rear + LiDAR cameras), facingMode: 'auto' may not pick the one your user wants. Enumerate cameras with CameraManager.enumerateCameras() and pass the chosen deviceId via cameraDeviceId. It takes precedence over facingMode — the session opens that camera and does not fall back on failure.
import { CameraManager, SladeID, FingerprintSteps } from '@sladeid/slade-id-sdk';
const cameras = await new CameraManager().enumerateCameras();
// Render `cameras` in a <select> and capture the user's pick as `deviceId`.
const session = sdk.createFingerprintSession(video, {
captureSteps: FingerprintSteps.rightHand(),
cameraDeviceId: deviceId,
});The browser only exposes stable deviceId values after the user has granted camera permission at least once on the origin. Call enumerateCameras() again after the session emits 'started' to refresh labels.
What can go wrong
'degraded'event fires — the SDK could not load its full quality-scoring stack and fell back to a coarser scorer. Captures still succeed; scores are less precise. If this persists in production, contact your Slade ID integration contact.- Capture loops endlessly in
'detecting'— the user is too close or too far. The default proximity range is0.75–1.35for slap captures and0.41–2.03for single-finger. See Tune capture quality to widen. QualityErrorwith codeQUALITY_GATE_FAILED— too many retries. RelaxqualityThreshold, improve lighting, or switch toqualityPolicy: 'any'.