Mercurial Hosting > traffic-intelligence
comparison scripts/classify-objects.py @ 1092:49c0bb6eacc2
minor modification
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 30 Jan 2019 16:51:52 -0500 |
parents | cc5cb04b04b0 |
children | 9f7a4a026dab |
comparison
equal
deleted
inserted
replaced
1091:3945d239634e | 1092:49c0bb6eacc2 |
---|---|
42 'bicycle': lambda s: bicLogNorm.pdf(s)} | 42 'bicycle': lambda s: bicLogNorm.pdf(s)} |
43 | 43 |
44 if args.plotSpeedDistribution: | 44 if args.plotSpeedDistribution: |
45 import matplotlib.pyplot as plt | 45 import matplotlib.pyplot as plt |
46 plt.figure() | 46 plt.figure() |
47 speeds = np.arange(0.1, args.maxSpeedDistributionPlot, 0.1) | |
47 for k in speedProbabilities: | 48 for k in speedProbabilities: |
48 plt.plot(np.arange(0.1, args.maxSpeedDistributionPlot, 0.1), [speedProbabilities[k](s/(3.6*params.videoFrameRate)) for s in np.arange(0.1, args.maxSpeedDistributionPlot, 0.1)], label = k) | 49 plt.plot(speeds, [speedProbabilities[k](s/(3.6*params.videoFrameRate)) for s in speeds], label = k) # the distribution parameters are in video intrinsic units, unit of distance per frame |
49 maxProb = -1. | 50 maxProb = -1. |
50 for k in speedProbabilities: | 51 for k in speedProbabilities: |
51 maxProb = max(maxProb, np.max([speedProbabilities[k](s/(3.6*params.videoFrameRate)) for s in np.arange(0.1, args.maxSpeedDistributionPlot, 0.1)])) | 52 maxProb = max(maxProb, np.max([speedProbabilities[k](s/(3.6*params.videoFrameRate)) for s in speeds])) |
52 plt.plot([classifierParams.minSpeedEquiprobable*3.6*params.videoFrameRate]*2, [0., maxProb], 'k-') | 53 plt.plot([classifierParams.minSpeedEquiprobable*3.6*params.videoFrameRate]*2, [0., maxProb], 'k-') |
53 plt.text(classifierParams.minSpeedEquiprobable*3.6*params.videoFrameRate, maxProb, 'threshold for equiprobable class') | 54 plt.text(classifierParams.minSpeedEquiprobable*3.6*params.videoFrameRate, maxProb, 'threshold for equiprobable class') |
54 plt.xlabel('Speed (km/h)') | 55 plt.xlabel('Speed (km/h)') |
55 plt.ylabel('Probability') | 56 plt.ylabel('Probability density function') |
56 plt.legend() | 57 plt.legend() |
57 plt.title('Probability Density Function') | 58 #plt.title('Probability Density Function') |
58 plt.show() | 59 plt.show() |
59 sys.exit() | 60 sys.exit() |
60 | 61 |
61 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, 'object', args.nObjects, withFeatures = True) | 62 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, 'object', args.nObjects, withFeatures = True) |
62 timeInterval = moving.TimeInterval.unionIntervals([obj.getTimeInterval() for obj in objects]) | 63 timeInterval = moving.TimeInterval.unionIntervals([obj.getTimeInterval() for obj in objects]) |