Object Tracker written in Python using dlib and OpenCV
Tracking can either be done using a live video from a webcam or using a video file.
To run the code using a video file use the following command line argument --
python object-tracker-single.py -v
For example, you can use the demo video provided with this code as --
python object-tracker-single.py -v demo-video-single.avi
To run the code using live video use the following command line argument --
python object-tracker-single.py -d
For example, on most systems device id 0 is the webcam attached.
python object-tracker-single.py -v docs/demo-single-video.avi
-lor `--dispLoc' command line option to display the locations of the tracked object as show below -
python object-tracker-single.py -v docs/demo-single-video.avi -l
NOTE -- If you want to do multi object tracking code, use the file
object-tracker-single.py. This is a hack to do multi-object tracking and hence the code slows down.
Once the code starts, it will start the video file or the live stream. To select the objects to be tracked, pause the video by pressing the p key.The next step is to create a bounding box around the object(s) to be tracked. Press the mouse to select the top-left pixel location of the object to be tracked and then release the mouse on the bottom-right location of the object to be tracked. Once, this is done press p to start the tracking. Also, if you want to discard the object, press the d key. In SINGLE OBJECT TRACKING MODE, you can only select one object but in MULTI OBJECT TRACKING MODE, you can select as many objects you want but at the cost of speed. Press esc anytime to gracefully quit the code.