Angular

Accura Face Plugin — Angular Integration Guide

This guide walks you through integrating the Accura Face Plugin into an Angular project (v17+) using standalone components.


Prerequisites

Before proceeding, ensure the following requirement is met:

  • accura.xml — Place your accura.xml license file in the public/ folder of your project as public/accura.xml. This file is required by the plugin to initialize the face detection engine. You can download it from here.

941KB
Open

Step 1: Initialize Project

Create a new Angular project with standalone component architecture. When prompted, select No for Server-Side Rendering (SSR):

npx ng new my-face-app --standalone
cd my-face-app
npm install

After scaffolding, open angular.json and ensure SSR and prerendering are explicitly disabled:


Step 2: Install Plugin

Install the Accura Face Plugin package from the npm registry:


Step 3: TypeScript Support

Angular enforces strict TypeScript compilation. Create a type declaration file at src/types.d.ts to declare the module and suppress resolution errors:

Ensure this file is included in your tsconfig.app.json's include array:


Step 4: Implementation

Generate the scanner component or create it manually at src/app/face-scanner/face-scanner.component.ts. The following snippet shows only the plugin import and initialization logic:


Step 5: Response Handling

When the plugin captures a valid face image, it invokes the base64Handler callback with an object containing a base64 property — a Data URL string representing the face image encoded in Base64 format (e.g., data:image/jpeg;base64,/9j/...).

What is Base64? Base64 is a binary-to-text encoding scheme that converts raw binary image data into a sequence of printable ASCII characters. The prefix segment (e.g., data:image/jpeg;base64,) conveys the MIME type, while the remainder is the encoded image payload. This format enables seamless transmission of binary content over text-based HTTP protocols without requiring binary transport mechanisms.

The following handler demonstrates forwarding the captured image to a remote verification endpoint:


Step 6: Demo Implementation

The following is the complete, production-ready component. Copy and paste it directly into src/app/face-scanner/face-scanner.component.ts. The original logic is preserved exactly as-is.


Step 7: Usage

Register and render the scanner component in app.component.ts:


Step 8: Running the Project

Last updated