diff scripts/classify-objects.py @ 946:e5970606066f

bug fix on list filtering (cannot remove while iterating) and motion prediction keeping the same features
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 21 Jul 2017 11:25:20 -0400
parents 0e63a918a1ca
children 053484e08947
line wrap: on
line diff
--- a/scripts/classify-objects.py	Thu Jul 20 14:29:46 2017 -0400
+++ b/scripts/classify-objects.py	Fri Jul 21 11:25:20 2017 -0400
@@ -102,15 +102,15 @@
                 if obj.getFirstInstant() <= frameNum: # if images are skipped
                     obj.initClassifyUserTypeHoGSVM(speedAggregationFunc, pedBikeCarSVM, bikeCarSVM, classifierParams.maxPedestrianSpeed, classifierParams.maxCyclistSpeed, classifierParams.nFramesIgnoreAtEnds, invHomography, intrinsicCameraMatrix, distortionCoefficients)
                     currentObjects.append(obj)
-                    objects.remove(obj)
+            objects[:] = [obj for obj in objects if obj.getFirstInstant() > frameNum]
 
             for obj in currentObjects:
                 if obj.getLastInstant() <= frameNum:  # if images are skipped
                     obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown)
                     pastObjects.append(obj)
-                    currentObjects.remove(obj)
                 else:
                     obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels, classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogNCellsPerBlock, classifierParams.hogBlockNorm)
+            currentObjects[:] = [obj for obj in objects if obj.getLastInstant() > frameNum]
         frameNum += 1
     
     for obj in currentObjects: