Source code for dvt.cli

# -*- coding: utf-8 -*-
"""Command line tool for evoking the toolkit.

This tool allows users to quickly apply pre-build pipelines to one or more
media files.

Example:
    Assuming we have an input named "video-clip.mp4", the following example
    shows the default usage of the command line interface:

    > python3 -m dvt video-viz video-clip.mp4

    This may take several minutes to complete. Some minimal logging information
    should display the annotators progress in your terminal. Once finished, you
    should have a new directory dvt-output-data that contains extracted
    metadata and frames from the source material. You can view the extracted
    information by starting a local http server:

    > cd dvt-output-data; python3 -m http.server --directory 

    And opening the following: http://0.0.0.0:8000/
"""

from sys import argv
from warnings import catch_warnings, simplefilter

from .pipeline.viz import VideoVizPipeline
from .pipeline.csv import VideoCsvPipeline


[docs]def run_cli(args=None): """Command line tool for evoking the toolkit. This function is not intended to be called directly from an external program. Run with caution. """ if args is None: args = argv try: with catch_warnings(): simplefilter("ignore") key = args[1] if key == "video-viz": pipeline = VideoVizPipeline.create_from_cli(args[2:]) elif key == "video-csv": pipeline = VideoCsvPipeline.create_from_cli(args[2:]) else: raise IndexError("Unknown pipeline: " + key) pipeline.run() except IndexError: print_help()