Mercurial Hosting > traffic-intelligence
diff scripts/learn-poi.py @ 818:181bcb6dad3a
added option to learn motion patterns and show to display results
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 21 Jun 2016 17:08:07 -0400 |
parents | 180b6b0231c0 |
children | 5a68779d7777 |
line wrap: on
line diff
--- a/scripts/learn-poi.py Mon Jun 20 10:56:41 2016 -0400 +++ b/scripts/learn-poi.py Tue Jun 21 17:08:07 2016 -0400 @@ -16,6 +16,7 @@ parser.add_argument('--covariance-type', dest = 'covarianceType', help = 'type of covariance of Gaussian model', default = "full") parser.add_argument('-w', dest = 'worldImageFilename', help = 'filename of the world image') parser.add_argument('-u', dest = 'unitsPerPixel', help = 'number of units of distance per pixel', type = float, default = 1.) +parser.add_argument('--display', dest = 'display', help = 'display points of interests', action = 'store_true') # default is manhattan distance args = parser.parse_args() @@ -44,18 +45,22 @@ if not model.converged_: print('Warning: model for '+gmmType+' points did not converge') # plot - fig = plt.figure() - if args.worldImageFilename is not None and args.unitsPerPixel is not None: - img = plt.imread(args.worldImageFilename) - plt.imshow(img) - labels = ml.plotGMMClusters(model, points, fig, nUnitsPerPixel = args.unitsPerPixel) - plt.axis('image') - plt.title(gmmType) - print(gmmType+' Clusters:\n{}'.format(ml.computeClusterSizes(labels, range(model.n_components)))) + if args.display: + fig = plt.figure() + if args.worldImageFilename is not None and args.unitsPerPixel is not None: + img = plt.imread(args.worldImageFilename) + plt.imshow(img) + labels = ml.plotGMMClusters(model, points, fig, nUnitsPerPixel = args.unitsPerPixel) + plt.axis('image') + plt.title(gmmType) + print(gmmType+' Clusters:\n{}'.format(ml.computeClusterSizes(labels, range(model.n_components)))) # save storage.savePOIs(args.databaseFilename, model, gmmType, gmmId) gmmId += 1 - + +if args.display: + plt.show() + # fig = plt.figure() # if args.worldImageFilename is not None and args.pixelsPerUnit is not None: # img = plt.imread(args.worldImageFilename)