.. include:: names.rst .. toctree:: :maxdepth: 2 Usage examples ############## This section contains an assortment of common usage examples, taken from the real world, as well as some terminal basics. We will explain each example shortly and move on quickly. If certain details are unclear, :doc:`parameters_trex` might help! Command-line ============ .. |movie| replace:: path/to/VIDEO.mp4 Often, the command-line interface is the most powerful way to use |trex|, as it allows you to automate tasks and run them in batch mode. The following examples will show you how to use the command-line interface to achieve common tasks. Just to note: you can reach most or all of these functions through the graphical user interface, using the same parameter names. Instructions from here should be fairly easy to transfer over! As you may know, simply starting the program without any arguments will open the graphical user interface. If you want to use the command-line interface, you have to specify the input using the ``-i`` option. For example, to open a video file, you would use:: trex -i webcam .. NOTE:: For multiple webcams, add the :param:`webcam_index` parameter. For example, to open the second webcam, use ``-i webcam -webcam_index 1``. You can also specify a video file using the ``-i`` option, e.g. ``-i /path/to/VIDEO.mp4``. .. raw:: html

This will open the webcam, if you have one installed and allow the program to use it, and use yolov8n-pose (see YOLOv11 models) to find you in the picture.

Just for fun, we also set a different :param:`detect_iou_threshold` which will change the IOU threshold for YOLO object detection - the higher the percentage, the more overlap between bounding boxes is allowed. The default is 70%, but we set it to 35%:: trex -i webcam -detect_iou_threshold 0.35 You may have already noticed that, by default, |trex| will see if a PV file already exists for the video you're trying to open. If it does, it will open it and you will end up in the tracking view immediately. However, we want to start over from scratch here - which can be enforced by adding the ``-task convert`` option in the same way:: trex -i webcam -task convert -detect_iou_threshold 0.35 The ``detect_iou_threshold`` here is simply the parameter :param:`detect_iou_threshold`, as described in the documentation. You may add any parameter found in there to the command-line, and it will be evaluated when the program starts - if there are any errors, an ``ERROR`` will be displayed somewhere in the command-line output. Those errors might also be interesting in case its not a user error, but a software bug (which you are welcome to `report here `_ on GitHub!). For example, we can also limit the number of individuals to track:: trex -i webcam -task convert -detect_iou_threshold 0.35 -track_max_individuals 1 This will force |trex| to (re-)convert the video to PV format, overwriting an existing ``VIDEO.pv`` file in the current folder. If you want the program to quit after it's done, you can use the ``-auto_quit`` option, which also exports trajectory data (if not disabled by ``-auto_no_tracking_data``). Other options omitted, this would look like this:: trex -i webcam [...] -auto_quit By default, |trex| will save the resulting .pv file in the same folder as the source video (as well as any exported trajectory data, which will land inside a ``data`` folder). If you want to save it somewhere else, you can use the ``-d`` option:: trex -i webcam [...] -d /path/to/output/to Parameters, often also called settings, can be stored in settings files. Almost all parameters can be passed to the program via such a settings file using the ``-s`` option:: trex -i webcam [...] -s /path/to/default.settings TRex: general usage examples **************************** .. NOTE:: Keep in mind that all parameters specified here in the command-line can also be accessed if you're already within the graphical user interface. Just type into the textfield on the bottom left of the screen and it will auto-complete parameter names for you. See also :doc:`gui`. Open a video:: trex -i