Skip to content

Defining your own ROIs

jcheung-0 edited this page Feb 22, 2021 · 3 revisions

If you don't like the ROIs that were automatically detected, you can create them manually using the roidefine.py script.

To do this, ensure you have started your ssh session using the -Y flag, which allows the server to send X11 windows to your computer (called X forwarding). Then, run the script with two required arguments: the first is the input file (a video whose ROIs you'd like to define, usually located in the input director) and the second is the output file (a text file containing the ROIs, usually located in the intermediate/rois directory and having the same name as the input file but ending in .txt instead of .mp4). For example, the following command will open up the test2.mp4 file and write new ROIs to the test2.txt file:

python3.7 scripts/roidefine.py input/test2.mp4 intermediate/rois/test2.txt

A screenshot of the first frame of the video will open up in an X11 window on your computer. (Be patient, this can be a little slow.) Click on "New ROI" and it will tell you which ROI it is drawing. Left-click to place each new vertex, and then right-click to close the polygon. When you're done, click on "Finish" and the window will close.

If an ROI file already exists in the location you have specified, the script will by default display them, and you can add new ones (there does not appear to be a way to modify existing ROIs). Alternatively, using the --overwrite flag as an additional argument to the script, you can simply create a new set of ROIs (the existing file will be ignored and overwritten).