From 7a8fad2ac1a69ebed9f105d885d6ae9ec3087b20 Mon Sep 17 00:00:00 2001 From: Mohammed Abdul Rahman <130785777+that-ar-guy@users.noreply.github.com> Date: Sat, 18 Jan 2025 23:52:22 +0530 Subject: [PATCH] Add/face detection model (#151) * face detection model added * title corrected * title updated/comments removed/links updated --- .../computer-vision/face-detection.md | 168 ++++++++++++++++++ docs/projects/computer-vision/index.md | 13 ++ 2 files changed, 181 insertions(+) create mode 100644 docs/projects/computer-vision/face-detection.md diff --git a/docs/projects/computer-vision/face-detection.md b/docs/projects/computer-vision/face-detection.md new file mode 100644 index 00000000..70916e08 --- /dev/null +++ b/docs/projects/computer-vision/face-detection.md @@ -0,0 +1,168 @@ +# Face Detection + + +### AIM +The goal of this project is to build a face detection system using OpenCV, which identifies faces in static images using Haar Cascades. + + +### DATASET LINK +For this project we are going to use the pretrained Haar Cascade XML file for face detection from OpenCV's Github repository. + +[https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml](https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml) + + +### NOTEBOOK LINK +[https://colab.research.google.com/drive/1upcl9sa5cL5fUuVLBG5IVuU0xPYs3Nwf#scrollTo=94ggAdg5AnUk](https://colab.research.google.com/drive/1upcl9sa5cL5fUuVLBG5IVuU0xPYs3Nwf#scrollTo=94ggAdg5AnUk) + + +### LIBRARIES NEEDED + +??? quote "LIBRARIES USED" + + - OpenCV + - Random + - Matplotlib + +--- + +### DESCRIPTION +This project involves building a face detection model using OpenCV's pre-trained Haar Cascade Classifiers to detect faces in images. + +!!! info "What is the requirement of the project?" + - A face detection system is needed for various applications such as security, attendance tracking, and facial recognition systems. + - This project demonstrates a basic use of computer vision techniques for detecting faces in static images. + + +??? info "Why is it necessary?" + - Face detection is the first crucial step in many computer vision applications such as face recognition and emotion analysis. + - It is an essential component in systems that require human identification or verification. + +??? info "How is it beneficial and used?" + - Face detection can be used in automation systems, for example, in attendance tracking, photo tagging, and security surveillance. + - It enables various applications in user experience enhancement and biometric systems. + +??? info "How did you start approaching this project? (Initial thoughts and planning)" + - I began by exploring OpenCV documentation, focusing on how to implement Haar Cascade for face detection. + - Initially, I focused on static image detection, planning to extend the project to video-based detection in the future. + +??? info "Mention any additional resources used (blogs, books, chapters, articles, research papers, etc.)." + - OpenCV documentation + - Book: "Learning OpenCV 3" by Adrian Kaehler and Gary Bradski + +--- + +### EXPLANATION + +#### DETAILS OF THE DIFFERENT FEATURES + + - Haar Cascade Classifier: A machine learning-based approach for detecting objects in images or video. It works by training on a large set of positive and negative images of faces. + - Cascade Classifier*: The classifier works through a series of stages, each aimed at increasing detection accuracy. + - Face Detection: The primary feature of this project is detecting human faces in static images, which is the first step in many facial recognition systems. + + + +--- + +#### PROJECT WORKFLOW + +=== "Step 1" + + Initial data exploration and understanding: + - Research the Haar Cascade method for face detection in OpenCV. + - Collect sample images for testing the model's performance. + + +=== "Step 2" + + Data cleaning and preprocessing: + - Ensure all input images are properly formatted (e.g., grayscale images for face detection). + - Resize or crop images to ensure optimal processing speed. + + +=== "Step 3" + + Feature engineering and selection: + - Use pre-trained Haar Cascade classifiers for detecting faces. + - Select the appropriate classifier based on face orientation and conditions (e.g., frontal face, profile). + + +=== "Step 4" + + Model training and evaluation: + - Use OpenCV's pre-trained Haar Cascade models. + - Test the detection accuracy on various sample images. + + +=== "Step 5" + + Model optimization and fine-tuning: + - Adjust parameters such as scale factor and minNeighbors to enhance accuracy. + - Experiment with different input image sizes to balance speed and accuracy. + + +=== "Step 6" + + Validation and testing: + - Validate the model's effectiveness on different test images, ensuring robust detection. + - Evaluate the face detection accuracy based on diverse lighting and image conditions. + + +--- + +#### PROJECT TRADE-OFFS AND SOLUTIONS + +=== "Trade Off 1" + - Accuracy vs. computational efficiency. + - Solution: Fine-tuned classifier parameters to ensure a balance between accuracy and speed. + +=== "Trade Off 2" + - Detection performance vs. image resolution. + - Solution: Optimized input image resolution and processing flow to ensure both fast processing and accurate detection. + +--- + +### SCREENSHOTS + +!!! success "Project workflow" + + ``` mermaid + graph LR + A[Start] --> B{Face Detected?} + B -->|Yes| C[Mark Face] + C --> D[Display Result] + B -->|No| F[Idle/Do Nothing] + ``` + +--- + +### CONCLUSION + +#### KEY LEARNINGS + +!!! tip "Insights gained from the data" + - Gained an understanding of face detection using Haar Cascades. + - Improved ability to optimize computer vision models for accuracy and speed. + +??? tip "Improvements in understanding machine learning concepts" + - Learned how to handle trade-offs between accuracy and speed in real-time applications. + - Gained hands-on experience with the implementation of object detection algorithms. + +??? tip "Challenges faced and how they were overcome" + - Challenge: Low detection accuracy in poor lighting conditions. + - Solution: Adjusted classifier parameters and added preprocessing steps to improve accuracy. + +--- + +#### USE CASES + +=== "Application 1" + + **Security Surveillance Systems** + + - Used for identifying individuals or monitoring for intruders in secure areas. + +=== "Application 2" + + **Attendance Systems** + + - Used to automate attendance tracking by detecting the faces of students or employees. diff --git a/docs/projects/computer-vision/index.md b/docs/projects/computer-vision/index.md index 1ba7b3c8..2780e68a 100644 --- a/docs/projects/computer-vision/index.md +++ b/docs/projects/computer-vision/index.md @@ -1,2 +1,15 @@ # Computer Vision 🎥 +