
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
facerecognitionlib
Advanced tools
>A modular and customizable face recognition camera utility for the web. Easily integrate webcam face detection and recognition with detector model, API calls, toast notifications, and custom UI.
A modular and customizable face recognition camera utility for the web. Easily integrate webcam face detection and recognition with detector model, API calls, toast notifications, and custom UI.
react-hot-toast
)uiOptions
npm install facerecognitionlib
import { opencam } from 'facerecognitionlib';
opencam({
detector: detectorInstance, // Required
onRecognized: async (data, stopCamera) => {
// Called on successful recognition
console.log("Recognized user:", data);
await markAttendance(data.user_id); // Your backend API call
stopCamera(); // Call this to stop webcam (optional)
},
recognitionUrl: 'http://your-server/recognize_face', // Required
recognitionPayloadBuilder: (base64Image) => ({
image: base64Image,
}),
});
Name | Type | Required | Description |
---|---|---|---|
detector | object | ✅ | Your face detection model instance (must have a .detect(canvas) method) |
onRecognized(data, stopCamera) | function | ✅ | Called when a face is recognized successfully. You can make API calls and manually call stopCamera() to end detection. |
recognitionUrl | string | ✅ | Endpoint to send base64 face image to for recognition |
recognitionPayloadBuilder() | function | ✅ | Function that returns payload for recognition API |
uiOptions | object | ❌ | Optional styling for video, canvas, status bar, and close button |
Pass a uiOptions object to override default styles.
uiOptions: {
videoStyles: {
width: "80vw",
height: "80vh",
borderRadius: "12px",
zIndex: 2000,
},
statusStyles: {
background: "rgba(0,0,0,0.7)",
fontSize: "1rem",
color: "#eee",
},
closeButtonStyles: {
top: "10px",
right: "10px",
backgroundColor: "red",
},
}
All uiOptions support inline styles (like style={{...}} in React).
You can handle success or failure of recognition and API calls via your own logic in onRecognized:
const onRecognized = async (data, stopCamera) => {
try {
const res = await axios.post('/api/mark_attendance', {
payloads
});
toast.success("Attendance marked!");
stopCamera(); // Optional — stop camera after success
} catch (err) {
toast.error("Failed to mark attendance.");
// Do not stop camera if you want to retry
}
};
Call stopCamera() from within your onRecognized callback to manually stop and clean up the camera view.
FAQs
>A modular and customizable face recognition camera utility for the web. Easily integrate webcam face detection and recognition with detector model, API calls, toast notifications, and custom UI.
The npm package facerecognitionlib receives a total of 0 weekly downloads. As such, facerecognitionlib popularity was classified as not popular.
We found that facerecognitionlib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.