view python/display-trajectories.py @ 263:c71540470057

reorganized loading trajectories and objects, added loading feature numbers for objects (the set of features grouped as one moving object
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 25 Jul 2012 22:06:51 -0400
parents 93c26e45efd8
children 20f9cd972dde
line wrap: on
line source

#! /usr/bin/env python

import sys,getopt

import storage
import cvutils

from numpy.linalg.linalg import inv
from numpy 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)