Skip to main content

Document Camera

The Document Camera component provides a live camera interface for capturing identity documents. It includes real-time feedback, auto-capture, and customizable UI elements.

Properties

  • isOpen: Bool
    Starts or stops the camera. When true, the camera feed and UI are rendered. Automatically set to false after capture or error.

  • showToggle: Bool
    Controls visibility of the Auto Capture toggle. Defaults to true.

  • toggleAutoCaptureDelay: Int (ms)
    Delay before enabling the Auto Capture toggle after animation completes.

  • showBackOfDocumentAnimation: Bool
    If true, shows back-side animation first. Defaults to false.

  • hints: DocumentDetectionHint
    Customizes user guidance messages. Unset fields use defaults.

  • successTime: Int (ms)
    Duration the success screen is shown after capture. Defaults to 500.

  • showHelpIcon: Bool
    Controls visibility of the Help icon. Defaults to true.

  • texts: Object
    Custom text for UI labels:

    • autoCaptureText
    • autoCaptureOnText
    • autoCaptureOffText
    • alertText
  • generalInfoTexts: [String, String]
    First string: smart capture instructions.
    Second string: tap-to-capture instructions.

Events

  • OpenEventName
    Triggered when the camera starts.

  • CloseEventName
    Triggered when the camera stops.

  • UserCanceledEventName
    Triggered when the user clicks the back arrow and exits the document camera without capturing an image.

  • FailureEventName
    Triggered on error. detail.error is of type DocCameraError.

  • CaptureEventName
    Triggered on successful capture. detail.captureResponse contains capture data.

  • DetectEventName
    Triggered on each frame detection. detail includes detectResponse and cameraState.

Type Definitions

type DocumentDetectionHint = {
moveCloserHint?: DocumentHint;
fixBlurHint?: DocumentHint;
fixGlareHint?: DocumentHint;
outOfFrameHint?: DocumentHint;
capturingHint?: DocumentHint;
};

type DocumentHint = {
title: string;
description: string;
};

type DocCameraError = {
code: string;
message: string;
};

type CaptureResponse = {
isGood?: boolean;
isSharp?: boolean;
isGlareFree?: boolean;
isAdequateDpi?: boolean;
isPortraitOrientation?: boolean;
failedChecks?: string[];
imageData?: ImageData;
imageWidth?: number;
imageHeight?: number;
};

type DetectResponse = {
isGood: boolean;
isSharp?: boolean;
isGlareFree?: boolean;
isAdequateDpi?: boolean;
failedChecks: string[];
dimensions?: Dimension;
corners?: MappedCorners;
};

type Dimension = {
width: number;
height: number;
};

type MappedCorners = {
topLeft: Corner;
topRight: Corner;
bottomLeft: Corner;
bottomRight: Corner;
};

type Corner = {
x: number;
y: number;
};

enum CameraState {
MoveCloser,
OutOfFrame,
FixGlare,
FixBlur,
Countdown,
Capturing,
TapToCapture
}