5#!/usr/bin/env python
"""
myseg - Command-line utility for searching and filtering videos based on their content

Usage:
  myseg filter <query> <files>... [-o <output_path>] [-m <model>] [-s <sr>] [-c <mc>] [--recreate-index] [--gpu-mode] [--open]
  myseg search <query> <files>... [-o <output_path>] [-m <model>] [-s <sr>] [-c <mc>] [--recreate-index] [--gpu-mode] 
  myseg describe <file> [-n <words>] [-m <model>] [--recreate-index] [--gpu-mode] [-c <mc>]
  myseg index <files> [-m <model>] [-s <sr>] [-c <mc>] [-r <ocr>] [--recreate-index] [--gpu-mode] 
  myseg sort <file> [-m <model>] [--gpu-mode] [--min-confidence <ct>] [--max-section-length <ms>] [-i <ignore>] [--open]
  myseg preview <file> [-m <model>] [--gpu-mode] [--min-confidence <ct>]
  myseg labels list [-m <model>]
  myseg labels search <regexp> [-m <model>]
  myseg models list
  myseg models info <model>
  myseg models freeze
  myseg models current
  myseg models use <model>
  myseg models download <model>
  myseg models remove <model>
  myseg models clear

Options:
  --version                       Show version.
  -h --help                       Show this screen.
  -o --output <dst>               Output file for supercut
  -s --sample-rate <sr>           How many frames to classify per second (default = 1)
  -c --min-confidence <mc>        Minimum prediction confidence required to consider a label (default depends on model)
  -m --model <model>              Model to use (use 'myseg models list' to see all available models)
  -n --number-of-words <words>    Number of words to describe the video with (default = 5)
  -t --max-section-length <ms>    Max number of seconds to show examples of a label in the sorted video (default = 5)
  -r --min-occurrences <ocr>      Minimum number of occurrences of a label in video required for it to be shown in the sorted video (default = 2)
  -i --ignore-labels <labels>     Labels to ignore when creating the sorted video video
  --title <title>                 Title to show at the beginning of the video (sort mode only)
  --gpu-mode                      Enable GPU mode
  --recreate-index                Recreate object index for file if it already exists
  --open                          Open filtered video after creating it (OS X only)
"""

import sys
import os
from docopt import docopt
                
if __name__ == '__main__':
    if 'CAFFE_ROOT' not in os.environ:
        print "You need to set your CAFFE_ROOT environment variable to point to your Caffe directory"
        sys.exit(1)
    sys.path.append(os.path.join(os.environ['CAFFE_ROOT'], 'python'))
    os.environ['GLOG_minloglevel'] = '3'
    import myseg
    args = docopt(__doc__, version="Myseg 0.1")
    sys.exit(myseg.main(args))

