Installing
The package can be installed on python 3.x simply using the pip command:
pip install offlinemot
Getting Started
After installing the library, and in order to test the example provided with it, the following lines can be used in as python commands:
import offlinemot
offlinemot.core.extract_paths() # no input to run the example video
In the first time this is ran, the example network model will be downloaded (around 250MB). And a window for the example video with the tracked objects will be shown.
The tracked objects will be surrounded with boxes in 5 different colors. Each color has a spicific meaning:
- Green: Pedestrian is detected.
- Blue: Cyclist is detected.
- Black: Car is detected.
- Red: The tracked object has failed the tracking step for the current frame
- White: The object is moving but still not classified to a class.
Of course, for a different case, the colors can be changed from the configs class instance here. This also depends on the number of classes to predict.
To control these parameters and many others, the commands to be run are:
cfg = offlinemot.config.configs()
#input can be named file, or empty for the default values.
cfg['colors_map'] = [(255,0,0),(0,0,255),(0,255,0)]
This will open a new text editor with the config.py file containing all of the parameters.
Running
To run it on some video, the command is:
cfg = offlinemot.config.configs()
offlinemot.core.extract_paths('path_to_video',config=cfg)
#[directory of the videos, leave empty to run the example video]
To show the result on the same video after post processing, use the command:
offlinemot.show_results.show_result('path_to_same_video')
#[directory of the videos, leave empty to run the example video]
Finally, to change the yolo network used in the package, the complete directory to 3 files need to be assigned with the configs class instance:
.pth for the model weights cfg[‘model_name’] = ‘directory’
.cfg for the Yolo configuration. cfg[‘model_config’] = ‘directory’
.names for a simple text file containing the names of the classes. cfg[‘class_file_name’] = ‘directory’