This project implements automatic hand tracking in videos using SAM2. It detects and masks hands in each frame of a video and outputs the processed video.
- Hand Detection: Detects hand locations in video frames.
- Hand Masking: Generates segmentation masks for detected hands using SAM.
- Video Processing: Outputs a processed video with hands masked.
- Python 3.8 or higher
- NVIDIA GPU with CUDA support (recommended for faster processing)
-
Clone the repository:
git clone https://github.com/your-repo/automatic-hand-tracking.git cd automatic-hand-tracking -
Install dependencies:
pip install -r requirements.txt
-
Download the SAM checkpoint:
wget -O sam_vit_b.pth https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
-
Prepare your input video and place it in the project directory.
-
Run the script to process the video:
python hand_tracking.py --input_path <input_video_path> --output_path <output_video_path>
Replace
<input_video_path>with the path to your input video and<output_video_path>with the desired output path. -
The processed video with masked hands will be saved at the specified output location.
See requirements.txt for a list of dependencies.
This project utilizes Segment Anything Model (SAM) by Facebook Research.