Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/safety-analysis.py @ 1150:14140b55e580
corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 28 May 2020 01:03:45 -0400 |
| parents | 8c0ec7e1eb8e |
| children | fe35473acee3 |
comparison
equal
deleted
inserted
replaced
| 1149:392db62ea1da | 1150:14140b55e580 |
|---|---|
| 16 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file (overrides the configuration file)') | 16 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file (overrides the configuration file)') |
| 17 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to analyse', type = int) | 17 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to analyse', type = int) |
| 18 # TODO analyze only | 18 # TODO analyze only |
| 19 parser.add_argument('--prediction-method', dest = 'predictionMethod', help = 'prediction method (constant velocity (cvd: vector computation (approximate); cve: equation solving; cv: discrete time (approximate)), normal adaptation, point set prediction)', choices = ['cvd', 'cve', 'cv', 'na', 'ps', 'mp']) | 19 parser.add_argument('--prediction-method', dest = 'predictionMethod', help = 'prediction method (constant velocity (cvd: vector computation (approximate); cve: equation solving; cv: discrete time (approximate)), normal adaptation, point set prediction)', choices = ['cvd', 'cve', 'cv', 'na', 'ps', 'mp']) |
| 20 parser.add_argument('-p', dest = 'prototypeDatabaseFilename', help = 'name of the database containing the prototypes') | 20 parser.add_argument('-p', dest = 'prototypeDatabaseFilename', help = 'name of the database containing the prototypes') |
| 21 parser.add_argument('-c', dest = 'minPrototypeNMatchings', help = 'minimum number of matchings per prototype', type = int, default = 1) | |
| 21 # parser.add_argument('--categorize', dest = 'categorize', help = 'computes interaction categories', action = 'store_true') TODO, add angle parameters in tracking.cfg - the safety analysis parameters should probably be spun off tracking.cfg | 22 # parser.add_argument('--categorize', dest = 'categorize', help = 'computes interaction categories', action = 'store_true') TODO, add angle parameters in tracking.cfg - the safety analysis parameters should probably be spun off tracking.cfg |
| 22 parser.add_argument('--no-motion-prediction', dest = 'noMotionPrediction', help = 'does not compute indicators like TTC depending on motion prediction', action = 'store_true') | 23 parser.add_argument('--no-motion-prediction', dest = 'noMotionPrediction', help = 'does not compute indicators like TTC depending on motion prediction', action = 'store_true') |
| 23 parser.add_argument('--pet', dest = 'computePET', help = 'computes PET', action = 'store_true') | 24 parser.add_argument('--pet', dest = 'computePET', help = 'computes PET', action = 'store_true') |
| 24 parser.add_argument('--display-cp', dest = 'displayCollisionPoints', help = 'display collision points', action = 'store_true') | 25 parser.add_argument('--display-cp', dest = 'displayCollisionPoints', help = 'display collision points', action = 'store_true') |
| 25 parser.add_argument('--nthreads', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1) | 26 parser.add_argument('--nthreads', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1) |
| 59 elif predictionMethod == 'mp': | 60 elif predictionMethod == 'mp': |
| 60 if args.prototypeDatabaseFilename is None: | 61 if args.prototypeDatabaseFilename is None: |
| 61 prototypes = storage.loadPrototypesFromSqlite(params.databaseFilename) | 62 prototypes = storage.loadPrototypesFromSqlite(params.databaseFilename) |
| 62 else: | 63 else: |
| 63 prototypes = storage.loadPrototypesFromSqlite(args.prototypeDatabaseFilename) | 64 prototypes = storage.loadPrototypesFromSqlite(args.prototypeDatabaseFilename) |
| 65 if args.minPrototypeNMatchings > 0: | |
| 66 prototypes = [p for p in prototypes if p.getNMatchings() >= args.minPrototypeNMatchings] | |
| 67 else: | |
| 68 nProto0Matching = 0 | |
| 69 for p in prototypes: | |
| 70 if p.getNMatchings() == 0: | |
| 71 nProto0Matching += 1 | |
| 72 print("Prototype {} has 0 matchings".format(p)) | |
| 73 if len(prototypes) == 0 or nProto0Matching > 0: | |
| 74 print('Database has {} prototypes without any matching. Exiting'.format(nProto0Matching)) | |
| 75 sys.exit() | |
| 64 for p in prototypes: | 76 for p in prototypes: |
| 65 p.getMovingObject().computeCumulativeDistances() | 77 p.getMovingObject().computeCumulativeDistances() |
| 66 predictionParameters = prediction.PrototypePredictionParameters(prototypes, params.nPredictedTrajectories, params.maxLcssDistance, params.minLcssSimilarity, params.lcssMetric, params.minFeatureTime, params.constantSpeedPrototypePrediction, params.useFeaturesForPrediction) | 78 predictionParameters = prediction.PrototypePredictionParameters(prototypes, params.nPredictedTrajectories, params.maxLcssDistance, params.minLcssSimilarity, params.lcssMetric, params.minFeatureTime, params.constantSpeedPrototypePrediction, params.useFeaturesForPrediction) |
| 67 # else: | 79 # else: |
| 68 # no else required, since parameters is required as argument | 80 # no else required, since parameters is required as argument |
