Mercurial Hosting > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
235:584613399513 | 236:eb4525853030 |
---|---|
1 #! /usr/bin/env python | |
2 | |
3 import sys,getopt | |
4 | |
5 import storage | |
6 import cvutils | |
7 | |
8 from numpy.linalg.linalg import inv | |
9 from numpy.lib.npyio import loadtxt | |
10 | |
11 options, args = getopt.getopt(sys.argv[1:], 'hi:d:t:o:f:',['help']) | |
12 # alternative long names are a pain to support ,'video-filename=','database-filename=', 'type=' | |
13 # todo parse the cfg file (problem, python ConfigParser needs section headers) | |
14 options = dict(options) | |
15 | |
16 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(): | |
17 print('Usage: {0} --help|-h -i video-filename -d database-filename [-t object_type] [-o image2world_homography] [-f first_frame]'.format(sys.argv[0])) | |
18 sys.exit() | |
19 | |
20 objectType = 'feature' | |
21 if '-t' in options.keys(): | |
22 objectType = options['-t'] | |
23 | |
24 objects = storage.loadTrajectoriesFromSqlite(options['-d'], objectType) | |
25 | |
26 homography = None | |
27 if '-o' in options.keys(): | |
28 homography = inv(loadtxt(options['-o'])) | |
29 firstFrameNum = 0 | |
30 if '-f' in options.keys(): | |
31 firstFrameNum = int(options['-f']) | |
32 | |
33 cvutils.displayTrajectories(options['-i'], objects, homography, firstFrameNum) |