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 (diff) d478d3122804 (current 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 | 5 files changed, 20 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
diff -r d478d3122804 -r 5654c9173548 scripts/classify-objects.py --- a/scripts/classify-objects.py Wed Jul 12 12:12:37 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), - 'cyclist': 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
diff -r d478d3122804 -r 5654c9173548 scripts/manual-video-analysis.py --- a/scripts/manual-video-analysis.py Wed Jul 12 12:12:37 2023 -0400 +++ b/scripts/manual-video-analysis.py Wed Jul 12 13:21:08 2023 -0400 @@ -29,7 +29,7 @@ 'car', 'pedestrian', 'motorcycle', - 'cyclist', + 'bicycle', 'bus', 'truck'] class UserConfiguration(object):
diff -r d478d3122804 -r 5654c9173548 scripts/polytracktopdtv.py --- a/scripts/polytracktopdtv.py Wed Jul 12 12:12:37 2023 -0400 +++ b/scripts/polytracktopdtv.py Wed Jul 12 13:21:08 2023 -0400 @@ -25,7 +25,7 @@ "1" -> "car" "2" -> "pedestrians" "3" -> "motorcycle" - "4" -> "cyclist" + "4" -> "bicycle" "5" -> "bus" "6" -> "truck" ... and other type if the objects_type table is defined in SQLite''' @@ -38,7 +38,7 @@ typeDict["1"] = "car" typeDict["2"] = "pedestrians" typeDict["3"] = "motorcycle" - typeDict["4"] = "cyclist" + typeDict["4"] = "bicycle" typeDict["5"] = "bus" typeDict["6"] = "truck"
diff -r d478d3122804 -r 5654c9173548 scripts/train-object-classification.py --- a/scripts/train-object-classification.py Wed Jul 12 12:12:37 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/", - 'cyclist': 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 != 'cyclist': + if k != moving.userTypeNames[4]: trainingSamplesPV[k], trainingLabelsPV[k] = trainingSamples, trainingLabels # Training the Support Vector Machine
diff -r d478d3122804 -r 5654c9173548 trafficintelligence/moving.py --- a/trafficintelligence/moving.py Wed Jul 12 12:12:37 2023 -0400 +++ b/trafficintelligence/moving.py Wed Jul 12 13:21:08 2023 -0400 @@ -1371,19 +1371,19 @@ 'car', 'pedestrian', 'motorcycle', - 'cyclist', + 'bicycle', 'bus', 'truck', 'automated'] 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'} + 1: 'bicycle', + 2: 'car', + 3: 'motorcycle', + 5: 'bus', + 6: 'train', + 7: 'truck'} userType2Num = utils.inverseEnumeration(userTypeNames) @@ -2073,7 +2073,7 @@ self.classifyUserTypeHoGSVMAtInstant(images[t], t, homography, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock) # compute P(Speed|Class) if speedProbabilities is None or self.aggregatedSpeed < minSpeedEquiprobable: # equiprobable information from speed - userTypeProbabilities = {userType2Num['car']: 1., userType2Num['pedestrian']: 1., userType2Num['cyclist']: 1.} + userTypeProbabilities = {userType2Num['car']: 1., userType2Num['pedestrian']: 1., userType2Num['bicycle']: 1.} else: userTypeProbabilities = {userType2Num[userTypename]: speedProbabilities[userTypename](self.aggregatedSpeed) for userTypename in speedProbabilities} # compute P(Class|Appearance)