check out the Output for this project below.
This Python program uses a webcam to track hand movements and overlays a video clip (a shield image) when two hands come close together. It creates a shield effect that responds to hand gestures.
- Real-time Hand Tracking: Detects hands using the webcam.
- Interactive Overlay: Displays a video clip when two hands are close.
- Dynamic Scaling: Adjusts the overlay size based on hand size.
- Video Output: Saves the processed video as an .mp4 file.
- OpenCV: For video capture and processing.
- cvzone: For hand detection.
- math: For calculating distances.
Install the dependencies with:
pip install opencv-python cvzone- Hand Detection: Captures video and detects hands in each frame.
- Distance Calculation: Measures distance between two hands and triggers the shield effect if the distance is below a threshold.
- Overlaying Video: Adds the shield video at the hand position, scaling it based on hand size.
- Saving Video: Saves the final video as
output.mp4.
- Ensure the webcam is connected.
- Place
shield.mp4in the script directory. - Run the script:
python hand_tracking_shield.py- The webcam feed will open. Bring your hands close together to see the shield effect.
- Press
qto exit the program.
- Threshold Distance: Adjust the
distancevariable to change when the shield appears. - Overlay Scaling: Modify the
mapFromTofunction to change the scaling of the shield.
- The video is saved as
output.mp4. - The live video feed is displayed with the overlay applied.
- Webcam Issues: Check webcam connection if the video stream doesn't open.
- Shield Video Problems: Ensure
shield.mp4is correctly formatted and located.
Surabhi Gade
Developed for a computer vision project with interactive hand tracking and video overlays.
Thanks to the creators of cvzone for the hand detection library.
