comparison scripts/display-trajectories.py @ 853:95e7622b11be

added option to limit the number of loaded objects
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 22 Sep 2016 16:49:43 -0400
parents 3058e00887bc
children 753a081989e2
comparison
equal deleted inserted replaced
852:45a53542e046 853:95e7622b11be
18 parser.add_argument('--undistorted-multiplication', dest = 'undistortedImageMultiplication', help = 'undistorted image multiplication', 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') 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) 20 parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to display', type = int)
21 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)
22 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)
23 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to display', type = int)
23 parser.add_argument('--save-images', dest = 'saveAllImages', help = 'save all images', action = 'store_true') 24 parser.add_argument('--save-images', dest = 'saveAllImages', help = 'save all images', action = 'store_true')
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) 25 parser.add_argument('--last-frame', dest = 'lastFrameNum', help = 'number of last frame number to save (for image saving, no display is made)', type = int)
25 26
26 args = parser.parse_args() 27 args = parser.parse_args()
27 28
28 if args.configFilename: # consider there is a configuration file 29 if args.configFilename is not None: # consider there is a configuration file
29 params = storage.ProcessParameters(args.configFilename) 30 params = storage.ProcessParameters(args.configFilename)
30 videoFilename = params.videoFilename 31 videoFilename = params.videoFilename
31 databaseFilename = params.databaseFilename 32 databaseFilename = params.databaseFilename
32 if params.homography is not None: 33 if params.homography is not None:
33 homography = inv(params.homography) 34 homography = inv(params.homography)
44 intrinsicCameraMatrix = None 45 intrinsicCameraMatrix = None
45 distortionCoefficients = [] 46 distortionCoefficients = []
46 undistortedImageMultiplication = None 47 undistortedImageMultiplication = None
47 firstFrameNum = 0 48 firstFrameNum = 0
48 49
49 if not args.configFilename and args.videoFilename is not None: 50 if args.configFilename is None and args.videoFilename is not None:
50 videoFilename = args.videoFilename 51 videoFilename = args.videoFilename
51 if not args.configFilename and args.databaseFilename is not None: 52 if args.configFilename is None and args.databaseFilename is not None:
52 databaseFilename = args.databaseFilename 53 databaseFilename = args.databaseFilename
53 if not args.configFilename and args.homographyFilename is not None: 54 if args.configFilename is None and args.homographyFilename is not None:
54 homography = inv(loadtxt(args.homographyFilename)) 55 homography = inv(loadtxt(args.homographyFilename))
55 if not args.configFilename and args.intrinsicCameraMatrixFilename is not None: 56 if args.configFilename is None and args.intrinsicCameraMatrixFilename is not None:
56 intrinsicCameraMatrix = loadtxt(args.intrinsicCameraMatrixFilename) 57 intrinsicCameraMatrix = loadtxt(args.intrinsicCameraMatrixFilename)
57 if not args.configFilename and args.distortionCoefficients is not None: 58 if args.configFilename is None and args.distortionCoefficients is not None:
58 distortionCoefficients = args.distortionCoefficients 59 distortionCoefficients = args.distortionCoefficients
59 if not args.configFilename and args.undistortedImageMultiplication is not None: 60 if args.configFilename is None and args.undistortedImageMultiplication is not None:
60 undistortedImageMultiplication = args.undistortedImageMultiplication 61 undistortedImageMultiplication = args.undistortedImageMultiplication
62
61 if args.firstFrameNum is not None: 63 if args.firstFrameNum is not None:
62 firstFrameNum = args.firstFrameNum 64 firstFrameNum = args.firstFrameNum
65 if args.nObjects is not None:
66 nObjects = args.nObjects
67 else:
68 nObjects = None
63 69
64 70 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType, nObjects)
65 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, args.trajectoryType)
66 boundingBoxes = storage.loadBoundingBoxTableForDisplay(databaseFilename) 71 boundingBoxes = storage.loadBoundingBoxTableForDisplay(databaseFilename)
67 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) 72 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)