Mercurial Hosting > traffic-intelligence
comparison scripts/learn-motion-patterns.py @ 910:b58a1061a717
loading is faster for longest object features
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 28 Jun 2017 15:36:25 -0400 |
parents | b297525b2cbf |
children | 89cc05867c4c |
comparison
equal
deleted
inserted
replaced
909:cd038493f8c6 | 910:b58a1061a717 |
---|---|
43 prototypeType = args.trajectoryType | 43 prototypeType = args.trajectoryType |
44 if args.trajectoryType == 'objectfeatures': | 44 if args.trajectoryType == 'objectfeatures': |
45 trajectoryType = 'object' | 45 trajectoryType = 'object' |
46 prototypeType = 'feature' | 46 prototypeType = 'feature' |
47 | 47 |
48 #features = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType) | |
49 objects = storage.loadTrajectoriesFromSqlite(args.databaseFilename, trajectoryType, withFeatures = (args.trajectoryType == 'objectfeatures'), objectNumbers = args.nTrajectories, timeStep = args.positionSubsamplingRate) | |
50 | |
51 if args.trajectoryType == 'objectfeatures': | 48 if args.trajectoryType == 'objectfeatures': |
52 features = [] | 49 objectFeatureNumbers = storage.loadObjectFeatureFrameNumbers(args.databaseFilename, objectNumbers = args.nTrajectories) |
53 for o in objects: | 50 featureNumbers = [] |
54 features += o.getNLongestFeatures(args.maxNObjectFeatures) | 51 for numbers in objectFeatureNumbers.values(): |
55 objects = features | 52 featureNumbers += numbers[:min(len(numbers), args.maxNObjectFeatures)] |
53 objects = storage.loadTrajectoriesFromSqlite(args.databaseFilename, 'feature', objectNumbers = featureNumbers, timeStep = args.positionSubsamplingRate) | |
54 else: | |
55 objects = storage.loadTrajectoriesFromSqlite(args.databaseFilename, trajectoryType, withFeatures = (args.trajectoryType == 'objectfeatures'), objectNumbers = args.nTrajectories, timeStep = args.positionSubsamplingRate) | |
56 | 56 |
57 trajectories = [o.getPositions().asArray().T for o in objects] | 57 trajectories = [o.getPositions().asArray().T for o in objects] |
58 | 58 |
59 lcss = utils.LCSS(metric = args.metric, epsilon = args.epsilon) | 59 lcss = utils.LCSS(metric = args.metric, epsilon = args.epsilon) |
60 nTrajectories = len(trajectories) | 60 nTrajectories = len(trajectories) |