Mercurial Hosting > traffic-intelligence
diff scripts/extract-appearance-images.py @ 947:053484e08947
found a more elegant solution, making a copy of the list to iterate
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 21 Jul 2017 11:31:42 -0400 |
parents | e5970606066f |
children | 933670761a57 |
line wrap: on
line diff
--- a/scripts/extract-appearance-images.py Fri Jul 21 11:25:20 2017 -0400 +++ b/scripts/extract-appearance-images.py Fri Jul 21 11:31:42 2017 -0400 @@ -68,7 +68,7 @@ if ret: if frameNum%50 == 0: print('frame number: {}'.format(frameNum)) - for obj in objects: + for obj in objects[:]: if obj.existsAtInstant(frameNum): if (10+frameNum-obj.getFirstInstant())%args.nFramesStep == 0: currentImageFeatures = set([f.num for f in obj.getFeatures() if f.existsAtInstant(frameNum)]) @@ -80,9 +80,8 @@ croppedImg = cvutils.imageBox(img, obj, frameNum, invHomography, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels) if croppedImg is not None: cv2.imwrite(args.directoryName+os.sep+moving.userTypeNames[obj.getUserType()]+os.sep+args.imagePrefix+'-{}-{}.png'.format(obj.getNum(), frameNum), croppedImg) -# elif obj.getLastInstant() == frameNum: -# objects.remove(obj) - objects[:] = [obj for obj in objects if obj.getLastInstant() != frameNum] + elif obj.getLastInstant() == frameNum: + objects.remove(obj) frameNum += 1 # todo speed info: distributions AND min speed equiprobable