Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/face detection model #151

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions docs/projects/computer-vision/face-detection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<!-- REMOVE ALL THE COMMENTED PART AFTER WRITING YOUR DOCUMENTATION. -->
<!-- THESE COMMENTS ARE PROVIDED SOLELY FOR YOUR ASSISTANCE AND TO OUTLINE THE REQUIREMENTS OF THIS PROJECT. -->
<!-- YOU CAN ALSO DESIGN YOUR PROJECT DOCUMENTATION AS YOU WISH BUT SHOULD BE UNDERSTANABLE TO A NEWBIE. -->
<!-- FOR REFERENCE, YOU MAY CONSULT THE FILE LOCATED AT 'docs\nlp\projects\twitter_sentiment_analysis.md'. -->

# Face Detection using OpenCV
that-ar-guy marked this conversation as resolved.
Show resolved Hide resolved


### 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.
[Click here to view the dataset](https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml)
that-ar-guy marked this conversation as resolved.
Show resolved Hide resolved


### NOTEBOOK LINK
[Click here to view the notebook](https://colab.research.google.com/drive/1upcl9sa5cL5fUuVLBG5IVuU0xPYs3Nwf#scrollTo=94ggAdg5AnUk)
that-ar-guy marked this conversation as resolved.
Show resolved Hide resolved


### LIBRARIES NEEDED
<!-- Mention it in bullet points either in numbering or simple dots -->
<!-- Mention all the libraries required for the project. You can add more or remove as necessary. -->

??? quote "LIBRARIES USED"

- OpenCV
- Numpy
- 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
<!-- Clearly define the step-by-step workflow followed in the project. You can add or remove points as necessary. -->

=== "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
<!-- Explain the trade-offs encountered during the project and the solutions you implemented. -->

=== "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
<!-- Include screenshots, graphs, and visualizations to illustrate your findings and workflow. -->

!!! 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
<!-- Mention at least two real-world applications of this project. -->

=== "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.
13 changes: 13 additions & 0 deletions docs/projects/computer-vision/index.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# Computer Vision 🎥

<div style="display: flex; flex-direction: column; gap: 10px;">

<!-- OpenCV Face Detection -->
<a href="face-detection" style="padding: 0 2px 0 16px; background-color: rgba(39, 39, 43, 0.4); border: 1px solid rgba(76, 76, 82, 0.4); border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); overflow: hidden; transition: transform 0.2s; display: flex; align-items: center;">
<img src="https://imerit.net/wp-content/uploads/2021/07/Face-Detection-in-Images-with-Bounding-Boxes.jpg" alt="OpenCV Logo" style="width: 300px; height: 150px; object-fit: cover; border-radius: 10px;" />
<div style="padding: 15px;">
<h2 style="margin: 0; font-size: 20px;">Face Detection Model</h2>
<p style="font-size: 16px;">Detecting faces in images using OpenCV's powerful Haar cascades.</p>
<p style="font-size: 12px;">📅 2025-01-16 | ⏱️ 10 mins</p>
</div>
</a>

</div>