Mercurial Hosting > traffic-intelligence
view python/display-trajectories.py @ 236:eb4525853030
added script to display trajectories
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 06 Jul 2012 01:03:52 -0400 |
parents | |
children | 93c26e45efd8 |
line wrap: on
line source
#! /usr/bin/env python import sys,getopt import storage import cvutils from numpy.linalg.linalg import inv from numpy.lib.npyio import loadtxt options, args = getopt.getopt(sys.argv[1:], 'hi:d:t:o:f:',['help']) # alternative long names are a pain to support ,'video-filename=','database-filename=', 'type=' # todo parse the cfg file (problem, python ConfigParser needs section headers) options = dict(options) if '--help' in options.keys() or '-h' in options.keys() or len(sys.argv) == 1 or not '-i' in options.keys() or not '-d' in options.keys(): print('Usage: {0} --help|-h -i video-filename -d database-filename [-t object_type] [-o image2world_homography] [-f first_frame]'.format(sys.argv[0])) sys.exit() objectType = 'feature' if '-t' in options.keys(): objectType = options['-t'] objects = storage.loadTrajectoriesFromSqlite(options['-d'], objectType) homography = None if '-o' in options.keys(): homography = inv(loadtxt(options['-o'])) firstFrameNum = 0 if '-f' in options.keys(): firstFrameNum = int(options['-f']) cvutils.displayTrajectories(options['-i'], objects, homography, firstFrameNum)