- Clone sam2 from the repository.
git clone https://github.com/facebookresearch/sam2.git && cd sam2
- Add path to sam2 to environment (i.e add to bashrc or zshrc)
echo "export SAM2_PATH=\"//home/$USER/sam2/\"" >> ~/.zshrc && source ~/.zshrc
or for bash
echo "export SAM2_PATH=\"//home/$USER/sam2/\"" >> ~/.bashrc && source ~/.bashrc
- Create virtual environment for python
python -m venv py-venv
- Activate virt environment
source py-venv/bin/activate
- Installing sam2 dependencies with the virtual python environment
pip3 install -e . && \
pip3 install -e ".[notebooks]"
- Install model checkpoints
cd checkpoints && \
./download_ckpts.sh && \
cd ..
- Finish installing dependencies used outside of sam2 requirements
pip3 install pandas
To deactivate the python virtual environment, simply run:
deactivate
- To run any of the python scripts, activate the python virtual environment:
source py-venv/bin/activate
- Then if you need your video split into individaul frames run:
./extractFramesFromVid.sh videos/<file of video>
- After this to get coordinates to start with run:
./extractCoord.py videos/<dir of jpgs created from previous script>
- Then finaly run the main script to get csv
./extractMasks.py videos/<dir of jpgs created from previous script>
If you want to get the csv points ploted onto a grid to see the range of movement for the object simply run
./trackmotion.py videos/<dir of jpgs created from previous script>
To deactivate the python virtual environment, simply run:
deactivate