A project to estimate the distance of a face from a camera using computer vision.
- π₯ 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.
Make sure you have the following installed:
- Python 3.7+
- OpenCV 4.x
- A working webcam or camera device
- Captures video frames from your webcam.
- Detects faces using the Haar Cascade model.
- 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}} ]
A project to estimate the distance of a face from a camera using computer vision.
- 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
Below is a demonstration of how the project works:
Image showing the face detection and distance measurement with a distance of 70.76cm from the camera
- π 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.
- β¨ Created by Haider Manzoor.
- Inspired by the awesome community of AI and computer vision enthusiasts.
- π Support for multiple objects.
- β‘ Improved performance with deep learning models.
- π Detailed analytics and visualizations.
We welcome contributions!
Feel free to create a pull request or open an issue to get involved.
This project is licensed under the MIT License.
π 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