HTML - Vanilla JS
Accura Face Plugin — Vanilla HTML Integration Guide
Prerequisites
Step 1: Implementation
<script type="module">
// Import the FacePlugin class directly from the Accura CDN.
import FacePlugin from "https://unpkg.com/accurafaceplugin/dist/accuramain.js";
// Declare a variable to hold the active plugin instance.
// This allows us to safely call destroy() before re-initializing.
let currentPlugin = null;
// Destroy any previously active instance before creating a new one.
// This prevents duplicate camera sessions or memory leaks.
if (currentPlugin) currentPlugin.destroy();
// Instantiate the FacePlugin with three required arguments:
// 1. Path to the accura.xml file (relative to the HTML file)
// 2. The callback function that receives the captured face image as base64
// 3. A configuration object to customize UI appearance and detection threshold
currentPlugin = new FacePlugin(
"./accura.xml", // Relative path to the XML license file
base64Handler, // Callback invoked upon successful face capture
{
threshold: 3, // Face detection threshold (1–100; higher = stricter)
textSize: "", // Overlay instruction text size (leave empty for default)
textColor: "", // Overlay instruction text color (leave empty for default)
textWeight: "", // Overlay instruction text font weight (leave empty for default)
textBgColor: "", // Background color of the text overlay (leave empty for default)
BodyBgColor: "", // Background color of the camera viewport (leave empty for default)
}
);
// Start the plugin engine. This opens the camera and begins face detection.
// The call is wrapped in try/catch to handle permission denials or initialization errors.
try {
await currentPlugin.start();
} catch (error) {
console.error("Failed to start plugin:", error);
}
</script>Step 2: Response Handling
Step 3: Demo Implementation
Last updated