- A lot of modules used in the code are part of openCV's contrib package (link here)
- Follow the steps for installation here
- Make sure to first uninstall cv2
pip uninstall cv2
- Then install contrib package
pip install opencv-contrib-python
- Make sure to first uninstall cv2
- Note: The contrib package has both main & contrib modules
- Make sure that you have the video(.mp4) and python file in the same directory.
- Run the code with the command
python3 object_tracking.py
- Then press s to select a ROI (region of image) using your mouse.
- Press Space or enter to confirm your selection.
- The video will keep on playing and your selected object will be tracked throughout.
- Repeat steps 3 and 4 to select & track multiple objects
Note: You can cancel your selection by pressing c
Note: You can try the same code with the other video files in the Data folder
- PyimageSearch
- Understanding the basics of object tracking & various tracking techinques here
- Video source