annotate scripts/classify-objects.py @ 1028:cc5cb04b04b0

major update using the trafficintelligence package name and install through pip
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 15 Jun 2018 11:19:10 -0400
parents a13f47c8931d
children 49c0bb6eacc2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
998
933670761a57 updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 993
diff changeset
1 #! /usr/bin/env python3
522
ce40a89bd6ae added functions for classification refactored from Sohail s work for TRB/TRC (to be tested)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2
1028
cc5cb04b04b0 major update using the trafficintelligence package name and install through pip
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1023
diff changeset
3 import sys, argparse
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
4
522
ce40a89bd6ae added functions for classification refactored from Sohail s work for TRB/TRC (to be tested)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5 import numpy as np
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
6 import cv2
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
7 from scipy.stats import norm, lognorm
522
ce40a89bd6ae added functions for classification refactored from Sohail s work for TRB/TRC (to be tested)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8
1028
cc5cb04b04b0 major update using the trafficintelligence package name and install through pip
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1023
diff changeset
9 from trafficintelligence import cvutils, moving, ml, storage, utils
cc5cb04b04b0 major update using the trafficintelligence package name and install through pip
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1023
diff changeset
10
788
5b970a5bc233 updated classifying code to OpenCV 3.x (bug in function to load classification models)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 687
diff changeset
11 # TODO add mode detection live, add choice of kernel and svm type (to be saved in future classifier format)
522
ce40a89bd6ae added functions for classification refactored from Sohail s work for TRB/TRC (to be tested)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
12
ce40a89bd6ae added functions for classification refactored from Sohail s work for TRB/TRC (to be tested)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene')
536
95276d310972 renamed TrackingParameters to ProcessParameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 529
diff changeset
14 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file', required = True)
686
cdee6a3a47b4 allowing alternate database and filename for classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 685
diff changeset
15 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file (overrides the configuration file)')
cdee6a3a47b4 allowing alternate database and filename for classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 685
diff changeset
16 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (overrides the configuration file)')
685
94b291a5f933 several updates for display
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 684
diff changeset
17 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to classify', type = int, default = None)
911
3dd5acfa1899 corrected potential issues with videos where one cannot reach a give frame from its number
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 905
diff changeset
18 parser.add_argument('--start-frame0', dest = 'startFrame0', help = 'starts with first frame for videos with index problem where frames cannot be reached', action = 'store_true')
683
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
19 parser.add_argument('--plot-speed-distributions', dest = 'plotSpeedDistribution', help = 'simply plots the distributions used for each user type', action = 'store_true')
854
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
20 parser.add_argument('--max-speed-distribution-plot', dest = 'maxSpeedDistributionPlot', help = 'if plotting the user distributions, the maximum speed to display (km/h)', type = float, default = 50.)
962
64259b9885bf verbose option to print classification information (more to add)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 947
diff changeset
21 parser.add_argument('--verbose', dest = 'verbose', help = 'verbose information', action = 'store_true')
536
95276d310972 renamed TrackingParameters to ProcessParameters
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 529
diff changeset
22
522
ce40a89bd6ae added functions for classification refactored from Sohail s work for TRB/TRC (to be tested)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
23 args = parser.parse_args()
901
753a081989e2 factorized some argument handling code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 899
diff changeset
24 params, videoFilename, databaseFilename, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum = storage.processVideoArguments(args)
812
21f10332c72b moved the classification parameters from tracking.cfg to a new classifier.cfg and made all classification parameters apparent
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 807
diff changeset
25 classifierParams = storage.ClassifierParameters(params.classifierFilename)
854
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
26 classifierParams.convertToFrames(params.videoFrameRate, 3.6) # conversion from km/h to m/frame
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
27
1023
a13f47c8931d work on processing large datasets (generate speed data)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1022
diff changeset
28 speedAggregationFunc = utils.aggregationFunction(classifierParams.speedAggregationMethod)
a13f47c8931d work on processing large datasets (generate speed data)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1022
diff changeset
29 if speedAggregationFunc is None:
683
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
30 sys.exit()
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
31
993
e8eabef7857c update to OpenCV3 for python
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 962
diff changeset
32 pedBikeCarSVM = ml.SVM_load(classifierParams.pedBikeCarSVMFilename)
e8eabef7857c update to OpenCV3 for python
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 962
diff changeset
33 bikeCarSVM = ml.SVM_load(classifierParams.bikeCarSVMFilename)
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
34
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
35 # log logistic for ped and bik otherwise ((pedBeta/pedAlfa)*((sMean/pedAlfa)**(pedBeta-1)))/((1+(sMean/pedAlfa)**pedBeta)**2.)
854
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
36 carNorm = norm(classifierParams.meanVehicleSpeed, classifierParams.stdVehicleSpeed)
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
37 pedNorm = norm(classifierParams.meanPedestrianSpeed, classifierParams.stdPedestrianSpeed)
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
38 # 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)
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
39 bicLogNorm = lognorm(classifierParams.scaleCyclistSpeed, loc = 0., scale = np.exp(classifierParams.locationCyclistSpeed))
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
40 speedProbabilities = {'car': lambda s: carNorm.pdf(s),
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
41 'pedestrian': lambda s: pedNorm.pdf(s),
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
42 'bicycle': lambda s: bicLogNorm.pdf(s)}
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
43
683
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
44 if args.plotSpeedDistribution:
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
45 import matplotlib.pyplot as plt
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
46 plt.figure()
682
fbe29be25501 corrected bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 680
diff changeset
47 for k in speedProbabilities:
854
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
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)
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
49 maxProb = -1.
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
50 for k in speedProbabilities:
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
51 maxProb = max(maxProb, np.max([speedProbabilities[k](s/(3.6*params.videoFrameRate)) for s in np.arange(0.1, args.maxSpeedDistributionPlot, 0.1)]))
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
52 plt.plot([classifierParams.minSpeedEquiprobable*3.6*params.videoFrameRate]*2, [0., maxProb], 'k-')
33d296984dd8 rework and more info on speed probabilities for classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 817
diff changeset
53 plt.text(classifierParams.minSpeedEquiprobable*3.6*params.videoFrameRate, maxProb, 'threshold for equiprobable class')
683
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
54 plt.xlabel('Speed (km/h)')
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
55 plt.ylabel('Probability')
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
56 plt.legend()
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
57 plt.title('Probability Density Function')
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
58 plt.show()
f3a0b652b590 added function to display the speed distributions and optimize a little going through objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 682
diff changeset
59 sys.exit()
682
fbe29be25501 corrected bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 680
diff changeset
60
686
cdee6a3a47b4 allowing alternate database and filename for classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 685
diff changeset
61 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, 'object', args.nObjects, withFeatures = True)
902
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
62 timeInterval = moving.TimeInterval.unionIntervals([obj.getTimeInterval() for obj in objects])
911
3dd5acfa1899 corrected potential issues with videos where one cannot reach a give frame from its number
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 905
diff changeset
63 if args.startFrame0:
3dd5acfa1899 corrected potential issues with videos where one cannot reach a give frame from its number
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 905
diff changeset
64 timeInterval.first = 0
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
65
686
cdee6a3a47b4 allowing alternate database and filename for classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 685
diff changeset
66 capture = cv2.VideoCapture(videoFilename)
993
e8eabef7857c update to OpenCV3 for python
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 962
diff changeset
67 width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
e8eabef7857c update to OpenCV3 for python
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 962
diff changeset
68 height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
69
935
0e63a918a1ca updated classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 928
diff changeset
70 #if undistort: # setup undistortion
928
063d1267585d work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 912
diff changeset
71 # [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients)
063d1267585d work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 912
diff changeset
72 # height, width = map1.shape
935
0e63a918a1ca updated classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 928
diff changeset
73 # newImgSize = (int(round(width*undistortedImageMultiplication)), int(round(height*undistortedImageMultiplication)))
0e63a918a1ca updated classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 928
diff changeset
74 # newCameraMatrix = cv2.getDefaultNewCameraMatrix(intrinsicCameraMatrix, newImgSize, True)
0e63a918a1ca updated classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 928
diff changeset
75 #else:
0e63a918a1ca updated classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 928
diff changeset
76 # newCameraMatrix = None
904
8f60ecfc2f06 work in progress, almost ready
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 902
diff changeset
77
684
6d2ece4aed7c bug forgot to svae objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 683
diff changeset
78 pastObjects = []
902
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
79 currentObjects = []
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
80 if capture.isOpened():
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
81 ret = True
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
82 frameNum = timeInterval.first
911
3dd5acfa1899 corrected potential issues with videos where one cannot reach a give frame from its number
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 905
diff changeset
83 if not args.startFrame0:
993
e8eabef7857c update to OpenCV3 for python
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 962
diff changeset
84 capture.set(cv2.CAP_PROP_POS_FRAMES, frameNum)
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
85 lastFrameNum = timeInterval.last
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
86
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
87 while ret and frameNum <= lastFrameNum:
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
88 ret, img = capture.read()
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
89 if ret:
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
90 if frameNum%50 == 0:
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
91 print('frame number: {}'.format(frameNum))
928
063d1267585d work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 912
diff changeset
92 #if undistort:
063d1267585d work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 912
diff changeset
93 # img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR)
947
053484e08947 found a more elegant solution, making a copy of the list to iterate
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 946
diff changeset
94 for obj in objects[:]:
912
fd057a6b04db corrected bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 911
diff changeset
95 if obj.getFirstInstant() <= frameNum: # if images are skipped
935
0e63a918a1ca updated classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 928
diff changeset
96 obj.initClassifyUserTypeHoGSVM(speedAggregationFunc, pedBikeCarSVM, bikeCarSVM, classifierParams.maxPedestrianSpeed, classifierParams.maxCyclistSpeed, classifierParams.nFramesIgnoreAtEnds, invHomography, intrinsicCameraMatrix, distortionCoefficients)
902
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
97 currentObjects.append(obj)
947
053484e08947 found a more elegant solution, making a copy of the list to iterate
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 946
diff changeset
98 objects.remove(obj)
902
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
99
947
053484e08947 found a more elegant solution, making a copy of the list to iterate
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 946
diff changeset
100 for obj in currentObjects[:]:
911
3dd5acfa1899 corrected potential issues with videos where one cannot reach a give frame from its number
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 905
diff changeset
101 if obj.getLastInstant() <= frameNum: # if images are skipped
902
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
102 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown)
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
103 pastObjects.append(obj)
947
053484e08947 found a more elegant solution, making a copy of the list to iterate
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 946
diff changeset
104 currentObjects.remove(obj)
817
b9ec0cc2677d corrected bug in classify-objects.py script
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 812
diff changeset
105 else:
928
063d1267585d work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 912
diff changeset
106 obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels, classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogNCellsPerBlock, classifierParams.hogBlockNorm)
962
64259b9885bf verbose option to print classification information (more to add)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 947
diff changeset
107 if args.verbose:
64259b9885bf verbose option to print classification information (more to add)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 947
diff changeset
108 print('obj {}@{}: {}'.format(obj.getNum(), frameNum, moving.userTypeNames[obj.userTypes[frameNum]]))
680
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
109 frameNum += 1
da1352b89d02 classification is working
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 536
diff changeset
110
902
c69a8defe5c3 changed workflow of classify objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 901
diff changeset
111 for obj in currentObjects:
899
1466a63dd1cf added a new classification parameter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 898
diff changeset
112 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown)
684
6d2ece4aed7c bug forgot to svae objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 683
diff changeset
113 pastObjects.append(obj)
6d2ece4aed7c bug forgot to svae objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 683
diff changeset
114 print('Saving user types')
686
cdee6a3a47b4 allowing alternate database and filename for classify-objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 685
diff changeset
115 storage.setRoadUserTypes(databaseFilename, pastObjects)