Mercurial Hosting > traffic-intelligence
comparison scripts/compute-clearmot.py @ 982:51d8406b2489
corrected bug when not using a homography and using a mask for CLEAR MOT metrics
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 27 Feb 2018 16:45:46 -0500 |
parents | 196a1fd498ba |
children | 933670761a57 |
comparison
equal
deleted
inserted
replaced
981:c3e690c5536e | 982:51d8406b2489 |
---|---|
31 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (for display)') | 31 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (for display)') |
32 parser.add_argument('--csv', dest = 'csvOutput', help = 'output comma-separated metrics', action = 'store_true') | 32 parser.add_argument('--csv', dest = 'csvOutput', help = 'output comma-separated metrics', action = 'store_true') |
33 args = parser.parse_args() | 33 args = parser.parse_args() |
34 | 34 |
35 if args.homographyFilename is not None: | 35 if args.homographyFilename is not None: |
36 homography = loadtxt(args.homographyFilename) | 36 invHomography = inv(loadtxt(args.homographyFilename)) |
37 else: | 37 else: |
38 homography = None | 38 invHomography = None |
39 | 39 |
40 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object') | 40 objects = storage.loadTrajectoriesFromSqlite(args.trackerDatabaseFilename, 'object') |
41 | 41 |
42 if args.maskFilename is not None: | 42 if args.maskFilename is not None: |
43 maskObjects = [] | 43 maskObjects = [] |
44 from matplotlib.pyplot import imread | 44 from matplotlib.pyplot import imread |
45 mask = imread(args.maskFilename) | 45 mask = imread(args.maskFilename) |
46 if len(mask) > 1: | 46 if len(mask) > 1: |
47 mask = mask[:,:,0] | 47 mask = mask[:,:,0] |
48 for obj in objects: | 48 for obj in objects: |
49 maskObjects += obj.getObjectsInMask(mask, inv(homography), 2) # TODO add option to keep object if at least one feature in mask | 49 maskObjects += obj.getObjectsInMask(mask, invHomography, 10) # TODO add option to keep object if at least one feature in mask |
50 objects = maskObjects | 50 objects = maskObjects |
51 | 51 |
52 annotations = storage.loadBBMovingObjectsFromSqlite(args.groundTruthDatabaseFilename) | 52 annotations = storage.loadBBMovingObjectsFromSqlite(args.groundTruthDatabaseFilename) |
53 for a in annotations: | 53 for a in annotations: |
54 a.computeCentroidTrajectory(homography) | 54 a.computeCentroidTrajectory(invHomography) |
55 | 55 |
56 if args.nFramesOffsetAnnotations is not None: | 56 if args.nFramesOffsetAnnotations is not None: |
57 for a in annotations: | 57 for a in annotations: |
58 a.shiftTimeInterval(args.nFramesOffsetAnnotations) | 58 a.shiftTimeInterval(args.nFramesOffsetAnnotations) |
59 | 59 |
79 intrinsicCameraMatrix = loadtxt(args.intrinsicCameraMatrixFilename) | 79 intrinsicCameraMatrix = loadtxt(args.intrinsicCameraMatrixFilename) |
80 else: | 80 else: |
81 intrinsicCameraMatrix = None | 81 intrinsicCameraMatrix = None |
82 firstInstant = args.firstInstant | 82 firstInstant = args.firstInstant |
83 lastInstant = args.lastInstant | 83 lastInstant = args.lastInstant |
84 cvutils.displayTrajectories(args.videoFilename, objects, {}, inv(homography), firstInstant, lastInstant, annotations = annotations, undistort = args.undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = args.distortionCoefficients, undistortedImageMultiplication = args.undistortedImageMultiplication, gtMatches = gtMatches, toMatches = toMatches) | 84 cvutils.displayTrajectories(args.videoFilename, objects, {}, invHomography, firstInstant, lastInstant, annotations = annotations, undistort = args.undistort, intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = args.distortionCoefficients, undistortedImageMultiplication = args.undistortedImageMultiplication, gtMatches = gtMatches, toMatches = toMatches) |
85 #print('Ground truth matches') | 85 #print('Ground truth matches') |
86 #print(gtMatches) | 86 #print(gtMatches) |
87 #print('Object matches') | 87 #print('Object matches') |
88 #rint toMatches | 88 #rint toMatches |