Skip to content

Smokey8979/Open-cv

Repository files navigation

👁️ OpenCV Experiments

A collection of real-time computer vision scripts built while learning OpenCV and MediaPipe. Webcam-based, runs locally, no cloud APIs.


Scripts

🧠 face_harmony.py — Golden Ratio Face Scorer

Uses MediaPipe Face Mesh (468 landmarks) to measure facial proportions in real time and compare them against the Golden Ratio (φ = 1.618). Computes eye distance, nose-mouth distance, and mouth-chin distance, then outputs a harmony score of 5, 7, or 9.

python face_harmony.py

Press ESC to exit

Dependencies: opencv-python, mediapipe


😐 face_mood.py — Real-time Emotion Detection

Detects faces using a Haar Cascade classifier, then runs each detected face through DeepFace to get the dominant emotion (happy, sad, angry, surprise, fear, disgust, neutral). Draws a labelled bounding box on each face.

python face_mood.py

Press q to exit

Dependencies: opencv-python, deepface


✌️ finger_distance.py — Thumb-to-Index Distance Measurement

Uses MediaPipe Hands to track hand landmarks and measure the real-world distance (in cm) between your thumb tip and index finger tip. Requires a one-time calibration step — hold a known 10 cm object between your fingers and press c.

python finger_distance.py

Press c to calibrate · ESC to exit

Dependencies: opencv-python, mediapipe


📦 object_detection.py — YOLOv5 Real-time Object Detection

Loads YOLOv5s via torch.hub and runs it on your webcam feed. Draws bounding boxes and class labels on every detected object in real time. Uses the small YOLOv5s model for speed — swap to yolov5m or yolov5l if you have the GPU for it.

python object_detection.py

Press q to exit
First run downloads YOLOv5 weights automatically (~14 MB)

Dependencies: opencv-python, torch, torchvision


🎯 tracking.py — CSRT Object Tracker

Select any object in the webcam frame using a drag-and-drop ROI selector, and the CSRT tracker will follow it. Shows "Tracking" in green when locked on, "Lost" in red when it loses the object.

python tracking.py

Draw a box around the object to track · Press q to exit

Dependencies: opencv-python


Setup

# Clone the repo
git clone https://github.com/Smokey8979/Open-cv.git
cd Open-cv

# Install dependencies
pip install -r requirements.txt

Python 3.9+ recommended. All scripts use your default webcam (cv2.VideoCapture(0)).


Requirements

opencv-python>=4.8.0
mediapipe>=0.10.0
deepface>=0.0.79
torch>=2.0.0
torchvision>=0.15.0

deepface pulls in TensorFlow — takes a while to install. If you only need the other scripts, skip it.


Topics

opencv · mediapipe · yolov5 · deepface · computer-vision · face-detection · emotion-detection · object-detection · object-tracking · hand-tracking · python · real-time


License

MIT — do whatever you want with it.

About

Open-cv stuff

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages