This project uses JavaScript combined with the face-api.js
library for real-time face detection and comparison. It enables seamless real-time face detection and identification by leveraging modern machine learning techniques in JavaScript.
- JavaScript: Core language for implementing functionality.
- face-api.js: A machine learning library built on top of TensorFlow.js that provides pre-trained models for face detection, landmark detection, face recognition, and more.
- Models like
tinyFaceDetector
,ssdMobilenetv1
, andfaceLandmark68Net
are preloaded usingface-api.js
. - The system integrates with a webcam to capture real-time video streams.
- Faces in the video stream are detected using the
detectAllFaces
method, which identifies faces and marks their landmarks (e.g., eyes, nose, mouth).
- Each detected face is processed to generate a descriptor, which is a numerical representation of key facial features.
- Pre-uploaded images of individuals are also processed to generate descriptors, which are then labeled (e.g., a person's name).
- Detected face descriptors are compared against the labeled descriptors using the
FaceMatcher
class fromface-api.js
. - A similarity threshold determines if a match is found, and the matched label (e.g., a name) is displayed on the video stream.
- Users can upload images via a form, where each image is labeled with the uploader's name.
- The server saves these images and updates a JSON file (
imageList.json
) with metadata such as filenames and labels.
- The
FaceMatcher
continuously compares faces detected in the webcam feed with stored descriptors. - Matching results are displayed on a canvas overlay, showing bounding boxes around faces and their corresponding labels.
Follow these steps to get the project running:
-
Clone the repository:
git clone https://github.com/Wilfred1097/face-recognition.git cd face-recognition
-
Install dependencies: Run the following command to install all required dependencies:
npm install
-
Start the server: Launch the server with:
npm start
-
Access the application: Open your browser and visit
http://127.0.0.1:3000
to access the real-time face recognition interface.
- Ensure your webcam is connected and accessible to allow the application to perform real-time face detection.
- Uploaded images should be renamed to include the full name of the individual (e.g.,
John_Doe.jpg
) before uploading.