Mercurial Hosting > traffic-intelligence
changeset 1228:5654c9173548
merged (bicycle)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 12 Jul 2023 13:21:08 -0400 |
parents | eb3936809ea5 (current diff) d478d3122804 (diff) |
children | 759d76d6d20c |
files | scripts/classify-objects.py scripts/manual-video-analysis.py scripts/polytracktopdtv.py scripts/train-object-classification.py trafficintelligence/moving.py |
diffstat | 3 files changed, 17 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/classify-objects.py Wed Jul 12 13:14:09 2023 -0400 +++ b/scripts/classify-objects.py Wed Jul 12 13:21:08 2023 -0400 @@ -37,9 +37,9 @@ pedNorm = norm(classifierParams.meanPedestrianSpeed, classifierParams.stdPedestrianSpeed) # numpy lognorm shape, loc, scale: shape for numpy is scale (std of the normal) and scale for numpy is exp(location) (loc=mean of the normal) bicLogNorm = lognorm(classifierParams.scaleCyclistSpeed, loc = 0., scale = np.exp(classifierParams.locationCyclistSpeed)) -speedProbabilities = {'car': lambda s: carNorm.pdf(s), - 'pedestrian': lambda s: pedNorm.pdf(s), - 'bicycle': lambda s: bicLogNorm.pdf(s)} +speedProbabilities = {moving.userTypeNames[1]: lambda s: carNorm.pdf(s), + moving.userTypeNames[2]: lambda s: pedNorm.pdf(s), + moving.userTypeNames[4]: lambda s: bicLogNorm.pdf(s)} if args.plotSpeedDistribution: import matplotlib.pyplot as plt
--- a/scripts/train-object-classification.py Wed Jul 12 13:14:09 2023 -0400 +++ b/scripts/train-object-classification.py Wed Jul 12 13:21:08 2023 -0400 @@ -22,9 +22,9 @@ args = parser.parse_args() classifierParams = storage.ClassifierParameters(args.configFilename) -imageDirectories = {'pedestrian': args.directoryName + "/Pedestrians/", - 'bicycle': args.directoryName + "/Cyclists/", - 'car': args.directoryName + "/Vehicles/"} +imageDirectories = {moving.userTypeNames[2]: args.directoryName + "/Pedestrians/", + moving.userTypeNames[4]: args.directoryName + "/Cyclists/", + moving.userTypeNames[1]: args.directoryName + "/Vehicles/"} trainingSamplesPBV = {} trainingLabelsPBV = {} @@ -39,11 +39,11 @@ print('Loading {} samples'.format(k)) trainingSamples, trainingLabels = cvutils.createHOGTrainingSet(v, moving.userType2Num[k], classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogBlockNorm, classifierParams.hogNCellsPerBlock) trainingSamplesPBV[k], trainingLabelsPBV[k] = trainingSamples, trainingLabels - if k != 'pedestrian': + if k != moving.userTypeNames[2]: trainingSamplesBV[k], trainingLabelsBV[k] = trainingSamples, trainingLabels - if k != 'car': + if k != moving.userTypeNames[1]: trainingSamplesPB[k], trainingLabelsPB[k] = trainingSamples, trainingLabels - if k != 'bicycle': + if k != moving.userTypeNames[4]: trainingSamplesPV[k], trainingLabelsPV[k] = trainingSamples, trainingLabels # Training the Support Vector Machine
--- a/trafficintelligence/moving.py Wed Jul 12 13:14:09 2023 -0400 +++ b/trafficintelligence/moving.py Wed Jul 12 13:21:08 2023 -0400 @@ -1376,14 +1376,14 @@ 'truck', 'automated'] -coco2UserTypes = {0: 2, 1: 4, 2: 1, 5: 5, 7: 6} -cocoUserTypeNames = {0: 'person', - 1: 'bicycle', - 2: 'car', - 3: 'motorcycle', - 5: 'bus', - 6: 'train', - 7: 'truck'} +coco2Types = {0: 2, 1: 4, 2: 1, 5: 5, 7: 6} +cocoTypeNames = {0: 'person', + 1: 'bicycle', + 2: 'car', + 3: 'motorcycle', + 5: 'bus', + 6: 'train', + 7: 'truck'} userType2Num = utils.inverseEnumeration(userTypeNames)