Mercurial Hosting > traffic-intelligence
changeset 348:c64a4f889b97
added safety analysis options to feature tracking (with default values for backward compatibility)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 26 Jun 2013 18:40:31 -0400 |
parents | 7b865f4174aa |
children | e3f910c26fae |
files | c/Parameters.cpp include/Parameters.hpp python/utils.py scripts/safety-analysis.py tracking.cfg |
diffstat | 5 files changed, 46 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/c/Parameters.cpp Wed Jun 26 17:28:45 2013 -0400 +++ b/c/Parameters.cpp Wed Jun 26 18:40:31 2013 -0400 @@ -18,7 +18,7 @@ ("help,h", "displays this help message") ("tf", "tracks features") ("gf", "groups features") - ("config-file", po::value<string>(&configurationFilename)->default_value("tracking.cfg"), "configuration file") + ("config-file", po::value<string>(&configurationFilename), "configuration file") ; po::positional_options_description p; @@ -56,11 +56,15 @@ ("max-distance", po::value<float>(&maxDistance), "maximum distance between features for grouping") ("min-velocity-cosine", po::value<float>(&minVelocityCosine), "minimum cosine of the angle between the velocity vectors for grouping") ("min-nfeatures-group", po::value<float>(&minNFeaturesPerGroup), "minimum average number of features per frame to create a vehicle hypothesis") - ; // ("max-uturn-cosine", po::value<float>(&maxUTurnCosine), "maximum cosine value to detect U-turn") // ("nframes-avoid-uturn", po::value<int>(&nFramesAvoidUTurn), "number of frames over which a feature should not make a U-turn") - - + // Safety Analysis + ("max-predicted-speed", po::value<float>(&maxPredictedSpeed)->default_value(50.), "maximum speed when predicting future motion (km/h)") + ("prediction-time-horizon", po::value<float>(&predictionTimeHorizon)->default_value(5.), "time horizon for collision prediction (s)") + ("collision-distance", po::value<float>(&collisionDistance)->default_value(1.8), "collision distance threshold (m)") + ("crossing-zones", po::value<bool>(&crossingZones)->default_value(false), "option to compute crossing zones and predicted PET") + ; + po::options_description cmdLine; cmdLine.add(onlyCmdLine).add(cmdLineAndFile); try { @@ -69,10 +73,16 @@ options(cmdLine).positional(p).allow_unregistered().run(), vm); notify(vm); + if (vm.count("config-file") == 0) { + cout << "Missing configuration file" << endl; + cout << cmdLine << endl; + exit(0); + } + cout << "Using configuration file " << configurationFilename << endl; ifstream configurationFile(configurationFilename.c_str()); - store(po::parse_config_file(configurationFile, cmdLineAndFile), vm); + store(po::parse_config_file(configurationFile, cmdLineAndFile, true), vm); notify(vm); parameterDescription = getParameterDescription(cmdLineAndFile, vm);
--- a/include/Parameters.hpp Wed Jun 26 17:28:45 2013 -0400 +++ b/include/Parameters.hpp Wed Jun 26 18:40:31 2013 -0400 @@ -48,6 +48,11 @@ float maxDistance; float minVelocityCosine; float minNFeaturesPerGroup; + // safety analysis + float maxPredictedSpeed; + float predictionTimeHorizon; + float collisionDistance; + bool crossingZones; std::string parameterDescription;
--- a/python/utils.py Wed Jun 26 17:28:45 2013 -0400 +++ b/python/utils.py Wed Jun 26 18:40:31 2013 -0400 @@ -450,6 +450,7 @@ self.homographyFilename = config.get(self.sectionHeader, 'homography-filename') self.homography = loadtxt(self.homographyFilename) self.firstFrameNum = config.getint(self.sectionHeader, 'frame1') + self.videoFrameRate = config.getfloat(self.sectionHeader, 'video-fps') ######################### # sqlite
--- a/scripts/safety-analysis.py Wed Jun 26 17:28:45 2013 -0400 +++ b/scripts/safety-analysis.py Wed Jun 26 18:40:31 2013 -0400 @@ -9,9 +9,10 @@ parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene') parser.add_argument('configFilename', help = 'name of the configuration file') -# parser.add_argument('-c', help = 'name of the configuration file') # +#parser.add_argument('--maxspeed', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) +#parser.add_argument('--time-horizon', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) args = parser.parse_args() -print(args) + # TODO work on the way to indicate an interaction definition # if False: # test if there is a configuration file? @@ -19,13 +20,12 @@ params.loadConfigFile(args.configFilename) # configuration parameters # TODO from command line -frameRate = 15 # frame per second -maxSpeed = 90/3.6/frameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways -timeHorizon= frameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) +maxSpeed = args.maxSpeed/3.6/params.videoFrameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways +timeHorizon= params.videoFrameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) collisionDistanceThreshold= 1.8 # m -computeCZ = True +computeCZ = False -display = False +# display = False # parameters for prediction methods constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(maxSpeed) @@ -53,17 +53,17 @@ interactions = events.createInteractions(objects) for inter in interactions: inter.computeIndicators() - # inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) + inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) storage.saveIndicators(params.databaseFilename, interactions) -if display: - plt.figure() - plt.axis('equal') - for inter in interactions[:2]: - for collisionPoints in inter.collisionPoints.values(): - for cp in collisionPoints: - plot([cp.x], [cp.y], 'x') +# if display: +# plt.figure() +# plt.axis('equal') +# for inter in interactions[:2]: +# for collisionPoints in inter.collisionPoints.values(): +# for cp in collisionPoints: +# plot([cp.x], [cp.y], 'x') # for the demo, output automatically a map # possibility to process longitudinal coords only
--- a/tracking.cfg Wed Jun 26 17:28:45 2013 -0400 +++ b/tracking.cfg Wed Jun 26 18:40:31 2013 -0400 @@ -10,7 +10,7 @@ load-features = false # display trajectories on the video display = false -# original video frame rate +# original video frame rate (number of frames/s) video-fps = 29.97 # number of digits of precision for all measurements derived from video # measurement-precision = 3 @@ -62,3 +62,12 @@ min-velocity-cosine = 0.8 # minimum average number of features per frame to create a vehicle hypothesis min-nfeatures-group = 3 +# Safety analysis +# maximum speed when predicting future motion (km/h) +max-predicted-speed = 50 +# time horizon for collision prediction (s) +prediction-time-horizon = 5 +# collision distance threshold (m) +collision-distance = 1.8 +# option to compute crossing zones and predicted PET +crossing-zones = false \ No newline at end of file