Skip to content

Estimate the distance of a face from a camera using real-time face detection and computer vision. This project leverages OpenCV and Haar Cascade to detect faces and measure their distance from the camera. It's simple, efficient, and ideal for educational purposes, DIY projects, and smart system integrations. πŸš€

Notifications You must be signed in to change notification settings

HaiderManzoor/FaceDistanceMeasure-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FaceDistanceMeasure πŸ“πŸ“Έ

A project to estimate the distance of a face from a camera using computer vision.


🌟 Features

  • πŸŽ₯ Real-time face detection.
  • πŸ“ Accurate distance measurement based on the size of the detected face.
  • πŸ“‚ Easy-to-use and extend for other object distance measurements.
  • 🧠 Utilizes OpenCV and Haar Cascade for efficient face detection.

πŸ”§ Requirements

Make sure you have the following installed:

  • Python 3.7+
  • OpenCV 4.x
  • A working webcam or camera device

πŸš€ How It Works

  1. Captures video frames from your webcam.
  2. Detects faces using the Haar Cascade model.
  3. Calculates the distance of the face from the camera using the formula: [ \text{Distance} = \frac{\text{Real Width of Object} \times \text{Focal Length}}{\text{Width of Object in Frame}} ]

FaceDistanceMeasure πŸ“πŸ“Έ

A project to estimate the distance of a face from a camera using computer vision.


πŸ› οΈ Installation

  1. Clone the repository:
    git clone https://github.com/your-username/FaceDistanceMeasure.git
    cd FaceDistanceMeasure
    

Install dependencies: pip install opencv-python Run the project: python distance.py

πŸ“Έ Demo

Below is a demonstration of how the project works:

FaceDistanceMeasure Demo
Image showing the face detection and distance measurement with a distance of 70.76cm from the camera

πŸ€” Use Cases

  • πŸ“š Educational Purposes: Learn the basics of computer vision and distance estimation.
  • πŸ› οΈ DIY Projects: Use it for robotics, surveillance, or smart home systems.
  • πŸš— Automotive Applications: Estimate distances for autonomous driving or parking systems.
  • πŸ›‘οΈ Security Systems: Monitor and measure proximity for restricted areas.

πŸ“ Acknowledgments

  • ✨ Created by Haider Manzoor.
  • Inspired by the awesome community of AI and computer vision enthusiasts.

πŸ—οΈ Future Improvements

  • πŸ” Support for multiple objects.
  • ⚑ Improved performance with deep learning models.
  • πŸ“Š Detailed analytics and visualizations.

πŸ’Œ Contributing

We welcome contributions!
Feel free to create a pull request or open an issue to get involved.


πŸ“œ License

This project is licensed under the MIT License.

πŸ“‚ Project Structure

πŸ“ Distance_measurement_using_single_camera
β”œβ”€β”€ distance.py                # Main script
β”œβ”€β”€ camera.py                  # Camera testing script
β”œβ”€β”€ Ref_image.png              # Reference image for focal length calculation
β”œβ”€β”€ haarcascade_frontalface_default.xml  # Haar Cascade model for face detection
└── README.md                  # Project documentation


About

Estimate the distance of a face from a camera using real-time face detection and computer vision. This project leverages OpenCV and Haar Cascade to detect faces and measure their distance from the camera. It's simple, efficient, and ideal for educational purposes, DIY projects, and smart system integrations. πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages