changeset 812:21f10332c72b

moved the classification parameters from tracking.cfg to a new classifier.cfg and made all classification parameters apparent
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 10 Jun 2016 17:07:36 -0400
parents 082a5c2685f4
children ef8795dba5ed
files classifier.cfg python/moving.py python/storage.py scripts/classify-objects.py scripts/train-object-classification.py tracking.cfg
diffstat 6 files changed, 160 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/classifier.cfg	Fri Jun 10 17:07:36 2016 -0400
@@ -0,0 +1,37 @@
+# filename of the general ped/cyc/veh SVM classifier
+pbv-svm-filename = modelPBV.xml
+# filename of the cyc/veh SVM classifier
+bv-svm-filename = modelBV.xml
+# percent increase of the max of width and height of the bounding box of features extracted for classification
+percent-increase-crop = 0.2
+# min number of pixels in cropped image to classify by SVM
+min-npixels-crop = 800
+# square size to resize image crops for HoG computation
+hog-rescale-size = 64
+# number of HoG orientation
+hog-norientations = 9
+# number of pixels per cell for HoG computation
+hog-npixels-cell = 8
+# number of cells per block for HoG computation
+hog-ncells-block = 2
+# method to aggregate road user speed
+speed-aggregation-method = median
+# number of frames to ignore at both ends of a series (noisy)
+nframes-ignore-at-ends = 2
+# quantile for the speed aggregation, if quantile is chosen
+speed-aggregation-quantile = 50
+# speed value below which all classes are equiprobable (distributions give odd values there) (km/h)
+min-speed-equiprobable = 3.33
+# maximum pedestrian speed (agregate: mean, median, 85th centile, etc.) 10 km/h
+max-ped-speed = 10.0
+# maximum cyclist speed (agregate: mean, median, 85th centile, etc.) 30 km/h (3xped)
+max-cyc-speed = 30.0
+# mean pedestrian speed and standard deviation (in a normal distribution) 4.91+-0.88 km/h
+mean-ped-speed = 4.91
+std-ped-speed = 0.88
+# mean cyclist speed and standard deviation (in a log-normal distribution) 11.+-4.83 km/h
+cyc-speed-loc = 2.31
+cyc-speed-scale = 0.42
+# mean vehicle speed and standard deviation (in a normal distribution) 18.45+-7.6 km/h
+mean-veh-speed = 18.45
+std-veh-speed = 7.6
--- a/python/moving.py	Fri Jun 10 15:44:08 2016 -0400
+++ b/python/moving.py	Fri Jun 10 17:07:36 2016 -0400
@@ -1542,17 +1542,20 @@
         
         self.userTypes = {}
 
-    def classifyUserTypeHoGSVMAtInstant(self, img, instant, homography, width, height, px = 0.2, py = 0.2, minNPixels = 800):
-        '''Extract the image box around the object and 
-        applies the SVM model on it'''
+    def classifyUserTypeHoGSVMAtInstant(self, img, instant, homography, width, height, px, py, minNPixels, rescaleSize, orientations, pixelsPerCell, cellsPerBlock):
+        '''Extracts the image box around the object
+        (of square size max(width, height) of the box around the features, 
+        with an added px or py for width and height (around the box))
+        computes HOG on this cropped image (with parameters rescaleSize, orientations, pixelsPerCell, cellsPerBlock)
+        and applies the SVM model on it'''
         croppedImg, yCropMin, yCropMax, xCropMin, xCropMax = cvutils.imageBox(img, self, instant, homography, width, height, px, py, minNPixels)
         if croppedImg is not None and len(croppedImg) > 0:
-            hog = cvutils.HOG(croppedImg)#HOG(image, rescaleSize = (64, 64), orientations=9, pixelsPerCell=(8, 8), cellsPerBlock=(2, 2), visualize=False, normalize=False)
+            hog = cvutils.HOG(croppedImg, rescaleSize, orientations, pixelsPerCell, cellsPerBlock, visualize=False, normalize=False)
             self.userTypes[instant] = int(self.appearanceClassifier.predict(hog))
         else:
             self.userTypes[instant] = userType2Num['unknown']
 
-    def classifyUserTypeHoGSVM(self, pedBikeCarSVM = None, width = 0, height = 0, homography = None, images = None, bikeCarSVM = None, pedBikeSpeedTreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), minSpeedEquiprobable = -1, speedProbabilities = None, aggregationFunc = median, nInstantsIgnoredAtEnds = 0, px = 0.2, py = 0.2, minNPixels = 800):
+    def classifyUserTypeHoGSVM(self, pedBikeCarSVM = None, width = 0, height = 0, homography = None, images = None, bikeCarSVM = None, pedBikeSpeedTreshold = float('Inf'), bikeCarSpeedThreshold = float('Inf'), minSpeedEquiprobable = -1, speedProbabilities = None, aggregationFunc = median, nInstantsIgnoredAtEnds = 0, px = 0.2, py = 0.2, minNPixels = 800, rescaleSize = (64, 64), orientations = 9, pixelsPerCell = (8,8), cellsPerBlock = (2,2)):
         '''Agregates SVM detections in each image and returns probability
         (proportion of instants with classification in each category)
 
@@ -1567,7 +1570,7 @@
         if len(self.userTypes) != self.length() and images is not None: # if classification has not been done previously
             for t in self.getTimeInterval():
                 if t not in self.userTypes:
-                    self.classifyUserTypeHoGSVMAtInstant(images[t], t, homography, width, height, px, py, minNPixels)
+                    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['bicycle']: 1.}
--- a/python/storage.py	Fri Jun 10 15:44:08 2016 -0400
+++ b/python/storage.py	Fri Jun 10 17:07:36 2016 -0400
@@ -1130,9 +1130,69 @@
 # Utils to read .ini type text files for configuration, meta data...
 #########################
 
+class ClassifierParameters(VideoFilenameAddable):
+    'Class for the parameters of object classifiers'
+    def loadConfigFile(self, filename):
+        from ConfigParser import ConfigParser
+        from os import path
+
+        config = ConfigParser()
+        config.readfp(FakeSecHead(openCheck(filename)))
+        self.sectionHeader = config.sections()[0]
+
+        self.pedBikeCarSVMFilename = config.get(self.sectionHeader, 'pbv-svm-filename')
+        self.bikeCarSVMFilename = config.get(self.sectionHeader, 'bv-svm-filename')
+        self.percentIncreaseCrop = config.getfloat(self.sectionHeader, 'percent-increase-crop')
+        self.minNPixels = config.getint(self.sectionHeader, 'min-npixels-crop')
+        x  = config.getint(self.sectionHeader, 'hog-rescale-size')
+        self.hogRescaleSize = (x, x)
+        self.hogNOrientations = config.getint(self.sectionHeader, 'hog-norientations')
+        x = config.getint(self.sectionHeader, 'hog-npixels-cell')
+        self.hogNPixelsPerCell = (x, x)
+        x = config.getint(self.sectionHeader, 'hog-ncells-block')
+        self.hogNCellsPerBlock = (x, x)
+        
+        self.speedAggregationMethod = config.get(self.sectionHeader, 'speed-aggregation-method')
+        self.nFramesIgnoreAtEnds = config.getint(self.sectionHeader, 'nframes-ignore-at-ends')
+        self.speedAggregationQuantile = config.getint(self.sectionHeader, 'speed-aggregation-quantile')
+        self.minSpeedEquiprobable = config.getfloat(self.sectionHeader, 'min-speed-equiprobable')
+        self.maxPedestrianSpeed = config.getfloat(self.sectionHeader, 'max-ped-speed')
+        self.maxCyclistSpeed = config.getfloat(self.sectionHeader, 'max-cyc-speed')
+        self.meanPedestrianSpeed = config.getfloat(self.sectionHeader, 'mean-ped-speed')
+        self.stdPedestrianSpeed = config.getfloat(self.sectionHeader, 'std-ped-speed')
+        self.locationCyclistSpeed = config.getfloat(self.sectionHeader, 'cyc-speed-loc')
+        self.scaleCyclistSpeed = config.getfloat(self.sectionHeader, 'cyc-speed-scale')
+        self.meanVehicleSpeed = config.getfloat(self.sectionHeader, 'mean-veh-speed')
+        self.stdVehicleSpeed = config.getfloat(self.sectionHeader, 'std-veh-speed')
+
+    def __init__(self, filename = None):
+        if filename is not None:
+            self.loadConfigFile(filename)
+
+    def convertToFrames(self, frameRate, speedRatio = 3.6):
+        '''Converts parameters with a relationship to time in 'native' frame time
+        speedRatio is the conversion from the speed unit in the config file
+        to the distance per second
+
+        ie param(config file) = speedRatio x fps x param(used in program)
+        eg km/h = 3.6 (m/s to km/h) x frame/s x m/frame'''
+        denominator = frameRate*speedRatio
+        #denominator2 = denominator**2
+        self.minSpeedEquiprobable = self.minSpeedEquiprobable/denominator
+        self.maxPedestrianSpeed = self.maxPedestrianSpeed/denominator
+        self.maxCyclistSpeed = self.maxCyclistSpeed/denominator
+        self.meanPedestrianSpeed = self.meanPedestrianSpeed/denominator
+        self.stdPedestrianSpeed = self.stdPedestrianSpeed/denominator
+        self.meanVehicleSpeed = self.meanVehicleSpeed/denominator
+        self.stdVehicleSpeed = self.stdVehicleSpeed/denominator
+        # special case for the lognormal distribution
+        self.locationCyclistSpeed = self.locationCyclistSpeed-log(denominator)
+        #self.scaleCyclistSpeed = self.scaleCyclistSpeed
+
+        
 class ProcessParameters(VideoFilenameAddable):
     '''Class for all parameters controlling data processing: input,
-    method parameters, etc. for tracking, classification and safety
+    method parameters, etc. for tracking and safety
 
     Note: framerate is already taken into account'''
 
@@ -1163,23 +1223,8 @@
         self.firstFrameNum = config.getint(self.sectionHeader, 'frame1')
         self.videoFrameRate = config.getfloat(self.sectionHeader, 'video-fps')
 
-        # Classification parameters
-        self.speedAggregationMethod = config.get(self.sectionHeader, 'speed-aggregation-method')
-        self.nFramesIgnoreAtEnds = config.getint(self.sectionHeader, 'nframes-ignore-at-ends')
-        self.speedAggregationQuantile = config.getint(self.sectionHeader, 'speed-aggregation-quantile')
-        self.minSpeedEquiprobable = config.getfloat(self.sectionHeader, 'min-speed-equiprobable')
-        self.minNPixels = config.getint(self.sectionHeader, 'min-npixels-crop')
-        self.pedBikeCarSVMFilename = config.get(self.sectionHeader, 'pbv-svm-filename')
-        self.bikeCarSVMFilename = config.get(self.sectionHeader, 'bv-svm-filename')
-        self.maxPedestrianSpeed = config.getfloat(self.sectionHeader, 'max-ped-speed')
-        self.maxCyclistSpeed = config.getfloat(self.sectionHeader, 'max-cyc-speed')
-        self.meanPedestrianSpeed = config.getfloat(self.sectionHeader, 'mean-ped-speed')
-        self.stdPedestrianSpeed = config.getfloat(self.sectionHeader, 'std-ped-speed')
-        self.locationCyclistSpeed = config.getfloat(self.sectionHeader, 'cyc-speed-loc')
-        self.scaleCyclistSpeed = config.getfloat(self.sectionHeader, 'cyc-speed-scale')
-        self.meanVehicleSpeed = config.getfloat(self.sectionHeader, 'mean-veh-speed')
-        self.stdVehicleSpeed = config.getfloat(self.sectionHeader, 'std-veh-speed')
-
+        self.classifierFilename = config.get(self.sectionHeader, 'classifier-filename')
+        
         # Safety parameters
         self.maxPredictedSpeed = config.getfloat(self.sectionHeader, 'max-predicted-speed')/3.6/self.videoFrameRate
         self.predictionTimeHorizon = config.getfloat(self.sectionHeader, 'prediction-time-horizon')*self.videoFrameRate
@@ -1198,26 +1243,6 @@
         if filename is not None:
             self.loadConfigFile(filename)
 
-    def convertToFrames(self, speedRatio = 3.6):
-        '''Converts parameters with a relationship to time in 'native' frame time
-        speedRatio is the conversion from the speed unit in the config file
-        to the distance per second
-
-        ie param(config file) = speedRatio x fps x param(used in program)
-        eg km/h = 3.6 (m/s to km/h) x frame/s x m/frame'''
-        denominator = self.videoFrameRate*speedRatio
-        denominator2 = denominator**2
-        self.minSpeedEquiprobable = self.minSpeedEquiprobable/denominator
-        self.maxPedestrianSpeed = self.maxPedestrianSpeed/denominator
-        self.maxCyclistSpeed = self.maxCyclistSpeed/denominator
-        self.meanPedestrianSpeed = self.meanPedestrianSpeed/denominator
-        self.stdPedestrianSpeed = self.stdPedestrianSpeed/denominator
-        self.meanVehicleSpeed = self.meanVehicleSpeed/denominator
-        self.stdVehicleSpeed = self.stdVehicleSpeed/denominator
-        # special case for the lognormal distribution
-        self.locationCyclistSpeed = self.locationCyclistSpeed-log(denominator)
-        #self.scaleCyclistSpeed = self.scaleCyclistSpeed
-
 class SceneParameters(object):
     def __init__(self, config, sectionName):
         from ConfigParser import NoOptionError
--- a/scripts/classify-objects.py	Fri Jun 10 15:44:08 2016 -0400
+++ b/scripts/classify-objects.py	Fri Jun 10 17:07:36 2016 -0400
@@ -12,8 +12,6 @@
 
 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene')
 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file', required = True)
-parser.add_argument('--kernel', dest = 'kernelType', help = 'kernel type for the support vector machine (SVM)', default = cv2.SVM_RBF, type = long)
-parser.add_argument('--svm', dest = 'svmType', help = 'SVM type', default = cv2.SVM_C_SVC, type = long)
 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file (overrides the configuration file)')
 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (overrides the configuration file)')
 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to classify', type = int, default = None)
@@ -22,6 +20,7 @@
 
 args = parser.parse_args()
 params = storage.ProcessParameters(args.configFilename)
+classifierParams = storage.ClassifierParameters(params.classifierFilename)
 
 if args.videoFilename is not None:
     videoFilename = args.videoFilename
@@ -32,31 +31,31 @@
 else:
     databaseFilename = params.databaseFilename
 
-params.convertToFrames(3.6)
+classifierParams.convertToFrames(params.videoFrameRate, 3.6) # conversion from km/h to m/s
 if params.homography is not None:
     invHomography = np.linalg.inv(params.homography)
 else:
     invHomography = None
 
-if params.speedAggregationMethod == 'median':
+if classifierParams.speedAggregationMethod == 'median':
     speedAggregationFunc = np.median
-elif params.speedAggregationMethod == 'mean':
+elif classifierParams.speedAggregationMethod == 'mean':
     speedAggregationFunc = np.mean
-elif params.speedAggregationMethod == 'quantile':
+elif classifierParams.speedAggregationMethod == 'quantile':
     speedAggregationFunc = lambda speeds: np.percentile(speeds, args.speedAggregationQuantile)
 else:
-    print('Unknown speed aggregation method: {}. Exiting'.format(params.speedAggregationMethod))
+    print('Unknown speed aggregation method: {}. Exiting'.format(classifierParams.speedAggregationMethod))
     sys.exit()
 
-pedBikeCarSVM = ml.SVM(args.svmType, args.kernelType)
-pedBikeCarSVM.load(params.pedBikeCarSVMFilename)
-bikeCarSVM = ml.SVM(args.svmType, args.kernelType)
-bikeCarSVM.load(params.bikeCarSVMFilename)
+pedBikeCarSVM = ml.SVM()
+pedBikeCarSVM.load(classifierParams.pedBikeCarSVMFilename)
+bikeCarSVM = ml.SVM()
+bikeCarSVM.load(classifierParams.bikeCarSVMFilename)
 
 # log logistic for ped and bik otherwise ((pedBeta/pedAlfa)*((sMean/pedAlfa)**(pedBeta-1)))/((1+(sMean/pedAlfa)**pedBeta)**2.)
-speedProbabilities = {'car': lambda s: norm(params.meanVehicleSpeed, params.stdVehicleSpeed).pdf(s),
-                      'pedestrian': lambda s: norm(params.meanPedestrianSpeed, params.stdPedestrianSpeed).pdf(s), 
-                      'bicycle': lambda s: lognorm(params.scaleCyclistSpeed, loc = 0., scale = np.exp(params.locationCyclistSpeed)).pdf(s)} # numpy lognorm shape, loc, scale: shape for numpy is scale (std of the normal) and scale for numpy is location (mean of the normal)
+speedProbabilities = {'car': lambda s: norm(classifierParams.meanVehicleSpeed, classifierParams.stdVehicleSpeed).pdf(s),
+                      'pedestrian': lambda s: norm(classifierParams.meanPedestrianSpeed, classifierParams.stdPedestrianSpeed).pdf(s), 
+                      'bicycle': lambda s: lognorm(classifierParams.scaleCyclistSpeed, loc = 0., scale = np.exp(classifierParams.locationCyclistSpeed)).pdf(s)} # numpy lognorm shape, loc, scale: shape for numpy is scale (std of the normal) and scale for numpy is location (mean of the normal)
 
 if args.plotSpeedDistribution:
     import matplotlib.pyplot as plt
@@ -96,25 +95,26 @@
         if ret:
             if frameNum%50 == 0:
                 print('frame number: {}'.format(frameNum))
-                currentObjects = []
-                for obj in objects:
-                    if obj.getLastInstant() < frameNum:
-                        obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities)
+            if params.undistort:
+                img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR)
+            currentObjects = []
+            for obj in objects:
+                inter = obj.getTimeInterval()
+                if inter.contains(frameNum):
+                    if inter.first == frameNum:
+                        obj.initClassifyUserTypeHoGSVM(speedAggregationFunc, pedBikeCarSVM, bikeCarSVM, classifierParams.maxPedestrianSpeed, classifierParams.maxCyclistSpeed, classifierParams.nFramesIgnoreAtEnds)
+                        currentObjects.append(obj)
+                    elif inter.last == frameNum:
+                        obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities)
                         pastObjects.append(obj)
                     else:
+                        obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, invHomography, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels, classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogNCellsPerBlock)
                         currentObjects.append(obj)
-                objects = currentObjects
-            if params.undistort:
-                img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR)
-            for obj in objects:
-                if obj.existsAtInstant(frameNum):
-                    if obj.getFirstInstant() == frameNum:
-                        obj.initClassifyUserTypeHoGSVM(speedAggregationFunc, pedBikeCarSVM, bikeCarSVM, params.maxPedestrianSpeed, params.maxCyclistSpeed, params.nFramesIgnoreAtEnds)
-                    obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, invHomography, width, height, 0.2, 0.2, 800) # px, py, pixelThreshold
+            objects = currentObjects
         frameNum += 1
     
     for obj in objects:
-        obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities)
+        obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities)
         pastObjects.append(obj)
     print('Saving user types')
     storage.setRoadUserTypes(databaseFilename, pastObjects)
--- a/scripts/train-object-classification.py	Fri Jun 10 15:44:08 2016 -0400
+++ b/scripts/train-object-classification.py	Fri Jun 10 17:07:36 2016 -0400
@@ -5,23 +5,30 @@
 from cv2 import SVM_RBF, SVM_C_SVC
 #from cv2.ml import SVM_RBF, SVM_C_SVC, ROW_SAMPLE # row_sample for layout in cv2.ml.SVM_load
 
-
-import cvutils, moving, ml
+import cvutils, moving, ml, storage
 
 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene')
 parser.add_argument('-d', dest = 'directoryName', help = 'parent directory name for the directories containing the samples for the different road users', required = True)
 parser.add_argument('--kernel', dest = 'kernelType', help = 'kernel type for the support vector machine (SVM)', default = SVM_RBF, type = long)
 parser.add_argument('--svm', dest = 'svmType', help = 'SVM type', default = SVM_C_SVC, type = long)
-# TODO make other SVM parameters apparent: C, C0, Nu, etc.
-parser.add_argument('-s', dest = 'rescaleSize', help = 'rescale size of image samples', default = 64, type = int)
-parser.add_argument('-o', dest = 'nOrientations', help = 'number of orientations in HoG', default = 9, type = int)
-parser.add_argument('-p', dest = 'nPixelsPerCell', help = 'number of pixels per cell', default = 8, type = int)
-parser.add_argument('-c', dest = 'nCellsPerBlock', help = 'number of cells per block', default = 2, type = int)
+parser.add_argument('--deg', dest = 'degree', help = 'SVM degree', default = 0, type = int)
+parser.add_argument('--gamma', dest = 'gamma', help = 'SVM gamma', default = 1, type = int)
+parser.add_argument('--coef0', dest = 'coef0', help = 'SVM coef0', default = 0, type = int)
+parser.add_argument('--cvalue', dest = 'cvalue', help = 'SVM Cvalue', default = 1, type = int)
+parser.add_argument('--nu', dest = 'nu', help = 'SVM nu', default = 0, type = int)
+parser.add_argument('--svmp', dest = 'svmP', help = 'SVM p', default = 0, type = int)
+parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the classifier configuration file', required = True)
+# parser.add_argument('-s', dest = 'rescaleSize', help = 'rescale size of image samples', default = 64, type = int)
+# parser.add_argument('-o', dest = 'nOrientations', help = 'number of orientations in HoG', default = 9, type = int)
+# parser.add_argument('-p', dest = 'nPixelsPerCell', help = 'number of pixels per cell', default = 8, type = int)
+# parser.add_argument('-c', dest = 'nCellsPerBlock', help = 'number of cells per block', default = 2, type = int)
+
 args = parser.parse_args()
+classifierParams = storage.ClassifierParameters(args.configFilename)
 
-rescaleSize = (args.rescaleSize, args.rescaleSize)
-nPixelsPerCell = (args.nPixelsPerCell, args.nPixelsPerCell)
-nCellsPerBlock = (args.nCellsPerBlock, args.nCellsPerBlock)
+# rescaleSize = (args.rescaleSize, args.rescaleSize)
+# nPixelsPerCell = (args.nPixelsPerCell, args.nPixelsPerCell)
+# nCellsPerBlock = (args.nCellsPerBlock, args.nCellsPerBlock)
 
 imageDirectories = {'pedestrian': args.directoryName + "/Pedestrians/",
                     'bicycle': args.directoryName + "/Cyclists/",
@@ -38,7 +45,7 @@
 
 for k, v in imageDirectories.iteritems():
     print('Loading {} samples'.format(k))
-    trainingSamples, trainingLabels = cvutils.createHOGTrainingSet(v, moving.userType2Num[k], rescaleSize, args.nOrientations, nPixelsPerCell, nCellsPerBlock)
+    trainingSamples, trainingLabels = cvutils.createHOGTrainingSet(v, moving.userType2Num[k], classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogNCellsPerBlock)
     trainingSamplesPBV[k], trainingLabelsPBV[k] = trainingSamples, trainingLabels
     if k != 'pedestrian':
 	trainingSamplesBV[k], trainingLabelsBV[k] = trainingSamples, trainingLabels
@@ -49,21 +56,21 @@
 
 # Training the Support Vector Machine
 print "Training Pedestrian-Cyclist-Vehicle Model"
-model = ml.SVM(args.svmType, args.kernelType)
+model = ml.SVM(args.svmType, args.kernelType, args.degree, args.gamma, args.coef0, args.cvalue, args.nu, args.svmP)
 model.train(np.concatenate(trainingSamplesPBV.values()), np.concatenate(trainingLabelsPBV.values()))
 model.save(args.directoryName + "/modelPBV.xml")
 
 print "Training Cyclist-Vehicle Model"
-model = ml.SVM(args.svmType, args.kernelType)
+model = ml.SVM(args.svmType, args.kernelType, args.degree, args.gamma, args.coef0, args.cvalue, args.nu, args.svmP)
 model.train(np.concatenate(trainingSamplesBV.values()), np.concatenate(trainingLabelsBV.values()))
 model.save(args.directoryName + "/modelBV.xml")
 
 print "Training Pedestrian-Cyclist Model"
-model = ml.SVM(args.svmType, args.kernelType)
+model = ml.SVM(args.svmType, args.kernelType, args.degree, args.gamma, args.coef0, args.cvalue, args.nu, args.svmP)
 model.train(np.concatenate(trainingSamplesPB.values()), np.concatenate(trainingLabelsPB.values()))
 model.save(args.directoryName + "/modelPB.xml")
 
 print "Training Pedestrian-Vehicle Model"
-model = ml.SVM(args.svmType, args.kernelType)
+model = ml.SVM(args.svmType, args.kernelType, args.degree, args.gamma, args.coef0, args.cvalue, args.nu, args.svmP)
 model.train(np.concatenate(trainingSamplesPV.values()), np.concatenate(trainingLabelsPV.values()))
 model.save(args.directoryName + "/modelPV.xml")
--- a/tracking.cfg	Fri Jun 10 15:44:08 2016 -0400
+++ b/tracking.cfg	Fri Jun 10 17:07:36 2016 -0400
@@ -80,34 +80,8 @@
 min-velocity-cosine = 0.8
 # minimum average number of features per frame to create a vehicle hypothesis
 min-nfeatures-group = 3.16747690802
-# Road user classification
-# min number of pixels in cropped image to classify by SVM
-min-npixels-crop = 400
-# method to aggregate road user speed
-speed-aggregation-method = median
-# number of frames to ignore at both ends of a series (noisy)
-nframes-ignore-at-ends = 2
-# quantile for the speed aggregation, if quantile is chosen
-speed-aggregation-quantile = 50
-# speed value below which all classes are equiprobable (distributions give odd values there) (km/h)
-min-speed-equiprobable = 3.33
-# filename of the general ped/cyc/veh SVM classifier
-pbv-svm-filename = modelPBV.xml
-# filename of the cyc/veh SVM classifier
-bv-svm-filename = modelBV.xml
-# maximum pedestrian speed (agregate: mean, median, 85th centile, etc.) 10 km/h
-max-ped-speed = 10.0
-# maximum cyclist speed (agregate: mean, median, 85th centile, etc.) 30 km/h (3xped)
-max-cyc-speed = 30.0
-# mean pedestrian speed and standard deviation (in a normal distribution) 4.91+-0.88 km/h
-mean-ped-speed = 4.91
-std-ped-speed = 0.88
-# mean cyclist speed and standard deviation (in a log-normal distribution) 11.+-4.83 km/h
-cyc-speed-loc = 2.31
-cyc-speed-scale = 0.42
-# mean vehicle speed and standard deviation (in a normal distribution) 18.45+-7.6 km/h
-mean-veh-speed = 18.45
-std-veh-speed = 7.6
+# name of the configuration file for all classifier information
+classifier-filename = classifier.cfg
 # Safety analysis
 # maximum speed when predicting future motion (km/h)
 max-predicted-speed = 50