diff trafficintelligence/cvutils.py @ 1245:371c718e57d7

interface updates
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 08 Feb 2024 16:10:54 -0500
parents 4cd8ace3552f
children ef68d4ba7dae
line wrap: on
line diff
--- a/trafficintelligence/cvutils.py	Thu Feb 08 15:04:56 2024 -0500
+++ b/trafficintelligence/cvutils.py	Thu Feb 08 16:10:54 2024 -0500
@@ -4,7 +4,7 @@
 from sys import stdout
 from os import listdir
 from subprocess import run
-from math import floor, log10, ceil
+from math import floor, log10, ceil, inf
 from time import time
 
 from numpy import dot, array, append, float32, loadtxt, savetxt, append, zeros, ones, identity, abs as npabs, logical_and, unravel_index, sum as npsum, isnan, mgrid, median, floor as npfloor, ceil as npceil, nonzero, dtype
@@ -312,7 +312,7 @@
         else:
             run(cmd)
         
-    def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1., nFramesStep = 1, saveAllImages = False, nZerosFilenameArg = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1., annotations = [], gtMatches = {}, toMatches = {}, colorBlind = False, **kwargs):
+    def displayTrajectories(videoFilename, objects, boundingBoxes = {}, homography = None, firstFrameNum = 0, lastFrameNum = None, printFrames = True, rescale = 1., nFramesStep = 1, saveAllImages = False, nZerosFilenameArg = None, undistort = False, intrinsicCameraMatrix = None, distortionCoefficients = None, undistortedImageMultiplication = 1., annotations = [], gtMatches = {}, toMatches = {}, colorBlind = False, **kwargs):
         '''Displays the objects overlaid frame by frame over the video '''
         if colorBlind:
             colorType = 'colorblind'
@@ -334,12 +334,8 @@
             ret = True
             frameNum = firstFrameNum
             capture.set(cv2.CAP_PROP_POS_FRAMES, firstFrameNum)
-            if lastFrameNumArg is None:
-                lastFrameNum = float("inf")
-            else:
-                lastFrameNum = lastFrameNumArg
             if nZerosFilenameArg is None:
-                if lastFrameNumArg is None:
+                if lastFrameNum is None or lastFrameNum == inf:
                     nZerosFilename = int(ceil(log10(objects[-1].getLastInstant())))
                 else:
                     nZerosFilename = int(ceil(log10(lastFrameNum)))