
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
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,base64Image) => {
// 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,base64Image) | 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,base64Image) => {
try {
const res = await axios.post('/api/mark_attendance', {
payloads,
base64Image //optional :depend on your route if you want you can pass it
});
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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.