Mercurial Hosting > traffic-intelligence
diff scripts/dltrack.py @ 1278:8e61ff3cd503 default tip
correct bug to take into account first frame num in config, and other related bugs in dltrack.py
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 27 Jun 2024 15:31:36 -0400 |
parents | b2f90cada58f |
children |
line wrap: on
line diff
--- a/scripts/dltrack.py Thu Jun 27 15:31:17 2024 -0400 +++ b/scripts/dltrack.py Thu Jun 27 15:31:36 2024 -0400 @@ -32,7 +32,7 @@ parser.add_argument('--distortion-coefficients', dest = 'distortionCoefficients', help = 'distortion coefficients', nargs = '*', type = float) parser.add_argument('--display', dest = 'display', help = 'show the raw detection and tracking results', action = 'store_true') parser.add_argument('--no-image-coordinates', dest = 'notSavingImageCoordinates', help = 'not saving the raw detection and tracking results', action = 'store_true') -parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to process', type = int, default = 0) +parser.add_argument('-f', dest = 'firstFrameNum', help = 'number of first frame number to process', type = int) parser.add_argument('-l', dest = 'lastFrameNum', help = 'number of last frame number to process', type = int, default = inf) parser.add_argument('--conf', dest = 'confidence', help = 'object confidence threshold for detection', type = float, default = 0.25) parser.add_argument('--bike-prop', dest = 'bikeProportion', help = 'minimum proportion of time a person classified as bike or motorbike to be classified as cyclist', type = float, default = 0.2) @@ -43,6 +43,8 @@ args = parser.parse_args() params, videoFilename, databaseFilename, homography, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum = storage.processVideoArguments(args) +print(params, videoFilename, databaseFilename, homography) + if args.homographyFilename is not None: homography = np.loadtxt(args.homographyFilename) if args.intrinsicCameraMatrixFilename is not None: @@ -56,7 +58,7 @@ elif args.configFilename is not None: lastFrameNum = params.lastFrameNum else: - lastFrameNum = args.lastFrameNum + lastFrameNum = np.inf if args.maskFilename is not None: mask = cv2.imread(args.maskFilename, cv2.IMREAD_GRAYSCALE) elif params is not None and params.maskFilename is not None: @@ -95,7 +97,7 @@ success, frame = capture.read() if not success: - print('Input {} could not be read. Exiting'.format(args.videoFilename)) + print('Input {} could not be read. Exiting'.format(videoFilename)) import sys; sys.exit() results = model.track(source=frame, tracker=args.trackerFilename, classes=list(moving.cocoTypeNames.keys()), conf=args.confidence, persist=True, verbose=False) @@ -237,7 +239,7 @@ else: f.positions = moving.Trajectory.fromPointList(list(f.tmpPositions.values())) if not args.notSavingImageCoordinates: - storage.saveTrajectoriesToSqlite(utils.removeExtension(args.databaseFilename)+'-bb.sqlite', list(objects.values()), 'object') + storage.saveTrajectoriesToSqlite(utils.removeExtension(databaseFilename)+'-bb.sqlite', list(objects.values()), 'object') # project and smooth for num, obj in objects.items(): features = obj.getFeatures() @@ -263,7 +265,7 @@ obj.features=[feature] obj.featureNumbers = [featureNum] #saving -storage.saveTrajectoriesToSqlite(args.databaseFilename, list(objects.values()), 'object') +storage.saveTrajectoriesToSqlite(databaseFilename, list(objects.values()), 'object')