Mercurial Hosting > traffic-intelligence
comparison scripts/play-video.py @ 385:1917db662aa7
added rescaling options to scripts play-video and display-trajectories
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 22 Jul 2013 18:33:47 -0400 |
parents | 1d90e9080cb2 |
children | 3058e00887bc |
comparison
equal
deleted
inserted
replaced
384:6da9cf5609aa | 385:1917db662aa7 |
---|---|
1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
2 | 2 |
3 import sys,getopt | 3 import sys, argparse |
4 import cvutils | 4 import cvutils |
5 | 5 |
6 options, args = getopt.getopt(sys.argv[1:], 'hi:f:',['help', 'fps=']) | |
7 options = dict(options) | |
8 print options | |
9 | 6 |
10 if '--help' in options.keys() or '-h' in options.keys() or len(sys.argv) == 1: | 7 parser = argparse.ArgumentParser(description='The program displays the video.') |
11 print('Usage: '+sys.argv[0]+' --help|-h -i video-filename [-f first_frame] [--fps frame_rate]') | 8 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file', required = True) |
12 sys.exit() | 9 parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to display', default = 0, type = int) |
10 parser.add_argument('--fps', dest = 'frameRate', help = 'approximate frame rate to replay', type = float) | |
11 parser.add_argument('-r', dest = 'rescale', help = 'rescaling factor for the displayed image', default = 1., type = float) | |
12 | |
13 args = parser.parse_args() | |
13 | 14 |
14 firstFrameNum = 0 | 15 firstFrameNum = 0 |
15 if '-f' in options.keys(): | 16 if args.firstFrameNum != None: |
16 firstFrameNum = int(options['-f']) | 17 firstFrameNum = args.firstFrameNum |
17 | 18 |
18 frameRate = -1 | 19 frameRate = -1 |
19 if '--fps' in options.keys(): | 20 if args.frameRate != None: |
20 frameRate = int(options['--fps']) | 21 frameRate = args.frameRate |
21 | 22 |
22 cvutils.playVideo(options['-i'], firstFrameNum, frameRate) | 23 cvutils.playVideo(args.videoFilename, firstFrameNum, frameRate, rescale = args.rescale) |