# HG changeset patch # User Nicolas Saunier # Date 1433863743 -7200 # Node ID cdee6a3a47b497a062b24650670d17c2d9a195a2 # Parent 94b291a5f9335042fbec8fce55ccfe92cb4a6029 allowing alternate database and filename for classify-objects diff -r 94b291a5f933 -r cdee6a3a47b4 python/utils.py --- a/python/utils.py Fri Jun 05 17:13:28 2015 +0200 +++ b/python/utils.py Tue Jun 09 17:29:03 2015 +0200 @@ -624,7 +624,11 @@ class LCSS(object): '''Class that keeps the LCSS parameters - and puts together the various computations''' + and puts together the various computations + + the methods with names starting with _ are not to be shadowed + in child classes, who will shadow the other methods, + ie compute and computeXX methods''' def __init__(self, similarityFunc, delta = float('inf'), aligned = False, lengthFunc = min): self.similarityFunc = similarityFunc self.aligned = aligned diff -r 94b291a5f933 -r cdee6a3a47b4 scripts/classify-objects.py --- a/scripts/classify-objects.py Fri Jun 05 17:13:28 2015 +0200 +++ b/scripts/classify-objects.py Tue Jun 09 17:29:03 2015 +0200 @@ -12,19 +12,24 @@ 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('-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) parser.add_argument('--plot-speed-distributions', dest = 'plotSpeedDistribution', help = 'simply plots the distributions used for each user type', action = 'store_true') parser.add_argument('--max-speed-distribution-plot', dest = 'maxSpeedDistributionPlot', help = 'if plotting the user distributions, the maximum speed to display', type = float, default = 50.) -#parser.add_argument('-u', dest = 'undistort', help = 'undistort the video (because features have been extracted that way)', action = 'store_true') -#parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to display', type = int) -#parser.add_argument('--last-frame', dest = 'lastFrameNum', help = 'number of last frame number to save (for image saving, no display is made)', type = int) -# parser.add_argument('--min-speed-equiprobable', dest = 'minSpeedEquiprobable', help = 'speed value below which all classes are equiprobable (distributions give odd values there) (km/h)', type = float, default = 3.33) -# parser.add_argument('--speed-aggregation', dest = 'speedAggregationMethod', help = 'method to aggregate road user speed', type = str, choices = ['median', 'mean', 'quantile'], default = 'median') -# parser.add_argument('--speed-aggregation-quantile', dest = 'speedAggregationQuantile', help = 'quantile for the speed aggregation, if quantile is chosen', type = int, default = 50) args = parser.parse_args() params = storage.ProcessParameters(args.configFilename) +if args.videoFilename is not None: + videoFilename = args.videoFilename +else: + videoFilename = params.videoFilename +if args.databaseFilename is not None: + databaseFilename = args.databaseFilename +else: + databaseFilename = params.databaseFilename + params.convertToFrames(3.6) if params.homography is not None: invHomography = np.linalg.inv(params.homography) @@ -61,15 +66,15 @@ plt.show() sys.exit() -objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename, 'object', args.nObjects, withFeatures = True) -#features = storage.loadTrajectoriesFromSqlite(params.databaseFilename, 'feature') +objects = storage.loadTrajectoriesFromSqlite(databaseFilename, 'object', args.nObjects, withFeatures = True) +#features = storage.loadTrajectoriesFromSqlite(databaseFilename, 'feature') intervals = [] for obj in objects: #obj.setFeatures(features) intervals.append(obj.getTimeInterval()) timeInterval = moving.unionIntervals(intervals) -capture = cv2.VideoCapture(params.videoFilename) +capture = cv2.VideoCapture(videoFilename) width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) height = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) @@ -108,4 +113,4 @@ obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities) pastObjects.append(obj) print('Saving user types') - storage.setRoadUserTypes(params.databaseFilename, pastObjects) + storage.setRoadUserTypes(databaseFilename, pastObjects)