Everything covered in this project was built to showcase my understanding—not as a polished production tool, but as a glimpse into how I think, learn, and build.
I wanted to touch every part of the problem: from basic ball tracking to experimenting with spin detection, even if some areas are still rough. The goal was to demonstrate curiosity, creativity, and a willingness to push beyond “just enough.”
I kept the code readable, modular, and transparent so you can follow my thought process. If something seems over-engineered or experimental, that’s intentional—it’s me exploring possibilities.
This project isn’t the final word—it’s an invitation to collaborate, improve, and make something genuinely useful together. I'm submitting this now, will submit my full fledge explanation of everything in sometime.
— Sarvesh Patil
"Made for Flickit" A Computer Vision project built for dynamic football analysis—tracking player-ball interactions in real-time. Features leg-specific touch counting, ball tracking, player velocity estimation, and basic ball rotation detection.
- Leg Touch Detection – Counts left and right leg touches accurately.
- Ball Tracking – Robust detection & tracking using pre-trained models and CV methods.
- Ball Rotation Estimation – Basic forward/backward spin detection.
- Player Velocity – Estimates player movement speed at each touch.
- Dynamic Overlays – Annotated video with live stats.
- Multi-Modal Detection – Color-based detection + Hough Circles + YOLO fusion.
- Kalman Filtering – Smooth trajectory prediction & noise reduction.
- Pose Estimation – MediaPipe Pose for 33-point landmarks.
- Performance Analytics – Touch heatmaps, statistics, and exportable data.
- Real-Time Ready – Works on live streams or video files.
- Python 3.8+
- OpenCV 4.8+ (with contrib)
- Optional: CUDA GPU for faster inference
- 8 GB RAM minimum (recommended)
pip install -r requirements.txtKey libraries:
opencv-python– Core CVmediapipe– Pose estimationnumpy,scipy– Math & signal processingultralytics– YOLO-based detection (optional)matplotlib– Plots & reporting
-
Clone the repository
git clone https://github.com/Light1300/Flickit cd Flickit/ -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install requirements
pip install -r requirements.txt
-
Verify installation
python -c "import cv2, mediapipe; print('Installation successful!')"
python main.py --video inputs/video.mp4Build and run on Docker:
docker build -t football-analyzer-gpu -f Dockerfile.gpu .
docker run <IMAGE_ID> --video /app/inputs/ssvid.net--Toe-Taps_360p.mp4 Custom input:
docker run <IMAGE_ID> --video <custom_path> python main.py \
--video input/football_video.mp4 \
--output output/analyzed_video.mp4 \
--confidence 0.8 \
--config config.yamlGenerated Files
-
Annotated Video (
output.mp4)- Shows touch counts (L/R), ball trajectory, velocity vectors, and rotation indicators.
-
Analysis Data (
output_analysis.json){ "summary": { "left_touches": 12, "right_touches": 8, "total_touches": 20 }, "touch_events": [ { "frame": 150, "timestamp": 5.0, "leg": "left", "ball_position": [320, 240], "player_velocity": 15.2, "confidence": 0.85 } ] }
- HSV color filtering for initial segmentation.
- Hough Circles & contour analysis for geometry validation.
- YOLOv8 (optional) for robust detection in complex scenes.
- Kalman filter to smooth noisy trajectories.
- MediaPipe Pose (33 landmarks) → track ankles/feet.
- Calculate Euclidean distance between ball center and feet.
- Debounce via cooldown frames to prevent double-counting.
- Player velocity derived from pose landmark displacement over time.
- Optical flow on ball ROI to estimate forward/backward spin.
- Frame skipping for performance trade-off.
- ROI-based processing for speed.
- NumPy vectorization to minimize overhead.
On 1080p video, mid-range CPU:
- Speed: 15–30 FPS.
- Touch detection accuracy: ~85–90% (varies with video quality).
- Ball tracking accuracy: ~90–95%.
Adjust detection sensitivity:
touch_threshold: 60
touch_cooldown: 10
confidence_threshold: 0.8Custom ball color ranges:
ball_detection:
red_ball:
lower_hsv: [0, 50, 50]
upper_hsv: [10, 255, 255]Change overlay colors:
colors = {
'left_leg': (255, 0, 0),
'right_leg': (0, 0, 255),
'ball': (0, 255, 255)
}- Could not open video → Check path/codec. Convert to MP4 if needed.
- Poor ball detection → Adjust HSV or use YOLO fallback.
- Inaccurate touches → Tune thresholds, ensure good video quality.
- Low performance → Lower resolution, skip frames, or use GPU.
python main.py --video input.mp4 --debugSaves intermediate frames, prints timing, and outputs diagnostics.
python main.py --video 0 # Webcam
python main.py --video rtmp://url # RTMP stream - Pose Estimation – MediaPipe Pose.
- Object Tracking – CSRT tracker.
- Color Space Analysis – HSV filtering.
- Morphology Ops – Opening/closing for noise cleanup.
- Kalman Filter – Smooth predictions.