This project provides a FastAPI-based web API for real-time face detection using a webcam and various computer vision feature detection techniques on uploaded images. It uses OpenCV and supports multiple algorithms like Harris, Shi-Tomasi, FAST, ORB, and Haar Cascade face detection.
- 📸 Camera-based Face Detection
- 🖼️ Image Upload for Feature Detection
- Harris Corner Detection
- Shi-Tomasi Corner Detection
- FAST Feature Detection
- ORB Feature Detection
- Haar Cascade Face Detection
Activates your webcam, captures a frame, detects faces using Haar Cascade, and returns an image with rectangles around detected faces.
Response:
image/pngwith detected faces outlined
Uploads an image and applies selected feature detection algorithms. Returns the processed image.
Form Data Parameters:
file: (required) The image file to uploaduse_harris: (optional)trueto apply Harris Corner Detectionuse_shi_tomasi: (optional)trueto apply Shi-Tomasi Corner Detectionuse_fast: (optional)trueto apply FAST feature detectionuse_orb: (optional)trueto apply ORB feature detectiondetect_faces: (optional)trueto apply face detection
Response:
image/pngwith detected features annotated
-
Clone the Repository:
git clone https://github.com/KyleJackson6/Facial-Recognition-.git cd Facial-Recognition- -
Install Dependencies:
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # or venv\Scripts\activate on Windows
Install packages:
pip install fastapi uvicorn opencv-python numpy
-
Ensure Haar Cascade File is Available:
Place
haarcascade_frontalface_default.xmlinside amodels/directory in the project root.
Start the FastAPI server:
uvicorn main:app --reloadThen go to http://127.0.0.1:8000/docs to use the Swagger UI interface.
.
├── main.py
├── models
│ └── haarcascade_frontalface_default.xml
├── face_detection_output.png # Output from camera face detection
- Make sure your webcam is connected and accessible for the
/camera_face_detection/endpoint. - All image processing is done using OpenCV.
- Feature colors:
- Harris: Red dots
- Shi-Tomasi: Green circles
- FAST: Yellow dots
- ORB: Pink dots
- Face detection: Red rectangles
This project is licensed under the MIT License.
Kyle Jackson