Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/compute-clearmot.py @ 785:3aa6102ccc12 dev
addressed issues with ground truth annotations shifted in time
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 03 Mar 2016 17:01:30 -0500 |
| parents | f8e0a8ea8402 |
| children | f6790357f53b |
comparison
equal
deleted
inserted
replaced
| 784:30bd0f2223b7 | 785:3aa6102ccc12 |
|---|---|
| 18 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the filename for the homography (if tracking was done using the homography)') | 18 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the filename for the homography (if tracking was done using the homography)') |
| 19 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True, type = float) | 19 parser.add_argument('-m', dest = 'matchingDistance', help = 'matching distance between tracker and ground truth trajectories', required = True, type = float) |
| 20 parser.add_argument('--mask', dest = 'maskFilename', help = 'filename of the mask file used to define the where objects were tracked') | 20 parser.add_argument('--mask', dest = 'maskFilename', help = 'filename of the mask file used to define the where objects were tracked') |
| 21 parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True, type = int) | 21 parser.add_argument('-f', dest = 'firstInstant', help = 'first instant for measurement', required = True, type = int) |
| 22 parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True, type = int) | 22 parser.add_argument('-l', dest = 'lastInstant', help = 'last instant for measurement', required = True, type = int) |
| 23 parser.add_argument('--offset', dest = 'nFramesOffsetAnnotations', help = 'number of frames to offset the ground truth annotations', type = int) | |
| 24 parser.add_argument('--displayOffset', dest = 'nFramesOffsetDisplay', help = 'number of frames to offset annotations and objects for display', type = int) | |
| 23 parser.add_argument('--display', dest = 'display', help = 'display the ground truth to object matches (graphically)', action = 'store_true') | 25 parser.add_argument('--display', dest = 'display', help = 'display the ground truth to object matches (graphically)', action = 'store_true') |
| 24 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (for display)') | 26 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (for display)') |
| 25 args = parser.parse_args() | 27 args = parser.parse_args() |
| 26 | 28 |
| 27 if args.homographyFilename is not None: | 29 if args.homographyFilename is not None: |
| 43 | 45 |
| 44 annotations = storage.loadBBMovingObjectsFromSqlite(args.groundTruthDatabaseFilename) | 46 annotations = storage.loadBBMovingObjectsFromSqlite(args.groundTruthDatabaseFilename) |
| 45 for a in annotations: | 47 for a in annotations: |
| 46 a.computeCentroidTrajectory(homography) | 48 a.computeCentroidTrajectory(homography) |
| 47 | 49 |
| 50 if args.nFramesOffsetAnnotations is not None: | |
| 51 for a in annotations: | |
| 52 a.shiftTimeInterval(args.nFramesOffsetAnnotations) | |
| 53 | |
| 48 if args.display: | 54 if args.display: |
| 49 motp, mota, mt, mme, fpt, gt, gtMatches, toMatches = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant, True) | 55 motp, mota, mt, mme, fpt, gt, gtMatches, toMatches = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant, True) |
| 50 else: | 56 else: |
| 51 motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant) | 57 motp, mota, mt, mme, fpt, gt = moving.computeClearMOT(annotations, objects, args.matchingDistance, args.firstInstant, args.lastInstant) |
| 52 | 58 |
| 54 print 'MOTP: {}'.format(motp) | 60 print 'MOTP: {}'.format(motp) |
| 55 print 'MOTA: {}'.format(mota) | 61 print 'MOTA: {}'.format(mota) |
| 56 print 'Number of missed objects.frames: {}'.format(mt) | 62 print 'Number of missed objects.frames: {}'.format(mt) |
| 57 print 'Number of mismatches: {}'.format(mme) | 63 print 'Number of mismatches: {}'.format(mme) |
| 58 print 'Number of false alarms.frames: {}'.format(fpt) | 64 print 'Number of false alarms.frames: {}'.format(fpt) |
| 65 | |
| 66 def shiftMatches(matches, offset): | |
| 67 shifted = {} | |
| 68 for k in matches: | |
| 69 shifted[k] = {t+offset:v for t, v in matches[k].iteritems()} | |
| 70 return shifted | |
| 71 | |
| 59 if args.display: | 72 if args.display: |
| 60 cvutils.displayTrajectories(args.videoFilename, objects, {}, inv(homography), args.firstInstant, args.lastInstant, annotations = annotations, gtMatches = gtMatches, toMatches = toMatches)#, rescale = args.rescale, nFramesStep = args.nFramesStep, saveAllImages = args.saveAllImages, undistort = (undistort or args.undistort), intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication) | 73 if args.nFramesOffsetDisplay is not None: |
| 74 firstInstant = args.firstInstant+args.nFramesOffsetDisplay | |
| 75 lastInstant = args.lastInstant+args.nFramesOffsetDisplay | |
| 76 for a in annotations: | |
| 77 a.shiftTimeInterval(args.nFramesOffsetDisplay) | |
| 78 for o in objects: | |
| 79 o.shiftTimeInterval(args.nFramesOffsetDisplay) | |
| 80 gtMatches = shiftMatches(gtMatches, args.nFramesOffsetDisplay) | |
| 81 toMatches = shiftMatches(toMatches, args.nFramesOffsetDisplay) | |
| 82 cvutils.displayTrajectories(args.videoFilename, objects, {}, inv(homography), firstInstant, lastInstant, annotations = annotations, gtMatches = gtMatches, toMatches = toMatches)#, rescale = args.rescale, nFramesStep = args.nFramesStep, saveAllImages = args.saveAllImages, undistort = (undistort or args.undistort), intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication) | |
| 61 | 83 |
| 62 #print('Ground truth matches') | 84 #print('Ground truth matches') |
| 63 #print(gtMatches) | 85 #print(gtMatches) |
| 64 #print('Object matches') | 86 #print('Object matches') |
| 65 #rint toMatches | 87 #rint toMatches |
