Skip to content

dharsh0507/face-detect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Face Detection Project

A Python-based face detection system using OpenCV and Haar Cascades for real-time face detection and dataset creation.

Features

  • Real-time face detection using webcam
  • Automatic face dataset creation
  • Face cropping and resizing
  • Image storage in organized directories

Requirements

  • Python 3.x
  • OpenCV (cv2)
  • Webcam/Camera access

Installation

  1. Install required dependencies:
pip install opencv-python
  1. Ensure your camera/webcam is connected and accessible

Project Structure

face-detection/
├── Day5_Code/
│   ├── dataset/
│   │   └── champ/          # Captured face images
│   ├── FaceDetection.py    # Main face detection script
│   ├── faceDataset.py      # Dataset creation script
│   └── haarcascade_frontalface_default.xml  # Haar cascade classifier
└── README.md

Usage

Face Detection with Dataset Creation

Run the main face detection script:

python Day5_Code/FaceDetection.py

Alternative Dataset Creation

Run the dataset creation script:

python Day5_Code/faceDataset.py

How It Works

  1. Camera Initialization: Opens webcam feed
  2. Face Detection: Uses Haar Cascade classifier to detect faces
  3. Image Processing: Converts to grayscale and crops detected faces
  4. Storage: Saves resized face images (130x100 pixels) to dataset folder
  5. Real-time Display: Shows live feed with face detection rectangles

Controls

  • ESC key: Exit the application
  • Automatic capture: Captures 30 face images automatically

Output

  • Face images are saved in dataset/champ/ directory
  • Images are numbered sequentially (1.jpg to 30.jpg)
  • Each image is resized to 130x100 pixels in grayscale

Troubleshooting

  • Camera not opening: Check camera permissions and ensure no other application is using the camera
  • No faces detected: Ensure proper lighting and face positioning
  • Import errors: Verify OpenCV installation with pip install opencv-python

Notes

  • The system captures 30 images by default
  • Face detection works best with good lighting conditions
  • Ensure face is clearly visible and properly positioned in the camera frame

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages