Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/display-trajectories.py @ 509:935430b1d408
corrected mask bug in feature tracking, updated display-trajectories to display on undistorted image
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 23 May 2014 16:27:26 -0400 |
| parents | 30fb60428e09 |
| children | 81ff62a7c39f |
comparison
equal
deleted
inserted
replaced
| 508:6f7fa0093162 | 509:935430b1d408 |
|---|---|
| 11 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file') | 11 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file') |
| 12 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file') | 12 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file') |
| 13 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file') | 13 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file') |
| 14 parser.add_argument('-t', dest = 'trajectoryType', help = 'type of trajectories to display', choices = ['feature', 'object'], default = 'feature') | 14 parser.add_argument('-t', dest = 'trajectoryType', help = 'type of trajectories to display', choices = ['feature', 'object'], default = 'feature') |
| 15 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the image to world homography file') | 15 parser.add_argument('-o', dest = 'homographyFilename', help = 'name of the image to world homography file') |
| 16 parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to display', default = 0, type = int) | 16 parser.add_argument('--intrinsic', dest = 'intrinsicCameraMatrixFilename', help = 'name of the intrinsic camera file') |
| 17 parser.add_argument('--distortion-coefficients', dest = 'distortionCoefficients', help = 'distortion coefficients', nargs = '*', type = float) | |
| 18 parser.add_argument('--undistorted-multiplication', dest = 'undistortedImageMultiplication', help = 'undistorted image multiplication', type = float) | |
| 19 parser.add_argument('-u', dest = 'undistort', help = 'undistort the video (because features have been extracted that way)', action = 'store_true') | |
| 20 parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to display', type = int) | |
| 17 parser.add_argument('-r', dest = 'rescale', help = 'rescaling factor for the displayed image', default = 1., type = float) | 21 parser.add_argument('-r', dest = 'rescale', help = 'rescaling factor for the displayed image', default = 1., type = float) |
| 18 parser.add_argument('-s', dest = 'nFramesStep', help = 'number of frames between each display', default = 1, type = int) | 22 parser.add_argument('-s', dest = 'nFramesStep', help = 'number of frames between each display', default = 1, type = int) |
| 19 parser.add_argument('--save-images', dest = 'saveAllImages', help = 'save all images', action = 'store_true') | 23 parser.add_argument('--save-images', dest = 'saveAllImages', help = 'save all images', action = 'store_true') |
| 20 parser.add_argument('--last-frame', dest = 'lastFrameNum', help = 'number of last frame number to save (for image saving, no display is made)', default = None, type = int) | 24 parser.add_argument('--last-frame', dest = 'lastFrameNum', help = 'number of last frame number to save (for image saving, no display is made)', type = int) |
| 21 | 25 |
| 22 args = parser.parse_args() | 26 args = parser.parse_args() |
| 23 | 27 |
| 24 homography = None | |
| 25 if args.configFilename: # consider there is a configuration file | 28 if args.configFilename: # consider there is a configuration file |
| 26 params = utils.TrackingParameters() | 29 params = storage.TrackingParameters(args.configFilename) |
| 27 params.loadConfigFile(args.configFilename) | |
| 28 videoFilename = params.videoFilename | 30 videoFilename = params.videoFilename |
| 29 databaseFilename = params.databaseFilename | 31 databaseFilename = params.databaseFilename |
| 30 homography = inv(loadtxt(params.homographyFilename)) | 32 homography = inv(params.homography) |
| 33 intrinsicCameraMatrix = params.intrinsicCameraMatrix | |
| 34 distortionCoefficients = params.distortionCoefficients | |
| 35 undistortedImageMultiplication = params.undistortedImageMultiplication | |
| 36 undistort = params.undistort | |
| 31 firstFrameNum = params.firstFrameNum | 37 firstFrameNum = params.firstFrameNum |
| 38 else: | |
| 39 homography = None | |
| 40 undistort = False | |
| 41 | |
| 32 | 42 |
| 33 if args.videoFilename != None: | 43 if not args.configFilename or args.videoFilename != None: |
| 34 videoFilename = args.videoFilename | 44 videoFilename = args.videoFilename |
| 35 if args.databaseFilename != None: | 45 if not args.configFilename or args.databaseFilename != None: |
| 36 databaseFilename = args.databaseFilename | 46 databaseFilename = args.databaseFilename |
| 37 if args.homographyFilename != None: | 47 if not args.configFilename or args.homographyFilename != None: |
| 38 homography = inv(loadtxt(args.homographyFilename)) | 48 homography = inv(loadtxt(args.homographyFilename)) |
| 39 if args.firstFrameNum != None: | 49 if not args.configFilename or args.intrinsicCameraMatrixFilename != None: |
| 50 intrinsicCameraMatrix = loadtxt(args.intrinsicCameraMatrixFilename) | |
| 51 if not args.configFilename or args.distortionCoefficients != None: | |
| 52 distortionCoefficients = args.distortionCoefficients | |
| 53 if not args.configFilename or args.undistortedImageMultiplication != None: | |
| 54 undistortedImageMultiplication = args.undistortedImageMultiplication | |
| 55 if not args.configFilename or args.firstFrameNum != None: | |
| 40 firstFrameNum = args.firstFrameNum | 56 firstFrameNum = args.firstFrameNum |
| 57 | |
| 41 | 58 |
| 42 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType) | 59 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType) |
| 43 boundingBoxes = storage.loadBoundingBoxTable(databaseFilename) | 60 boundingBoxes = storage.loadBoundingBoxTable(databaseFilename) |
| 44 cvutils.displayTrajectories(videoFilename, objects, boundingBoxes, homography, firstFrameNum, args.lastFrameNum, rescale = args.rescale, nFramesStep = args.nFramesStep, saveAllImages = args.saveAllImages) | 61 cvutils.displayTrajectories(videoFilename, objects, boundingBoxes, homography, firstFrameNum, args.lastFrameNum, rescale = args.rescale, nFramesStep = args.nFramesStep, saveAllImages = args.saveAllImages, undistort = (undistort or args.undistort), intrinsicCameraMatrix = intrinsicCameraMatrix, distortionCoefficients = distortionCoefficients, undistortedImageMultiplication = undistortedImageMultiplication) |
