Mercurial > hg > nsaunier > traffic-intelligence
comparison python/cvutils.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 | c03d2c0a4c04 |
comparison
equal
deleted
inserted
replaced
| 946:e5970606066f | 947:053484e08947 |
|---|---|
| 325 if undistort: | 325 if undistort: |
| 326 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) | 326 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) |
| 327 if printFrames: | 327 if printFrames: |
| 328 print('frame {0}'.format(frameNum)) | 328 print('frame {0}'.format(frameNum)) |
| 329 # plot objects | 329 # plot objects |
| 330 for obj in objects: | 330 for obj in objects[:]: |
| 331 if obj.existsAtInstant(frameNum): | 331 if obj.existsAtInstant(frameNum): |
| 332 if not hasattr(obj, 'projectedPositions'): | 332 if not hasattr(obj, 'projectedPositions'): |
| 333 obj.projectedPositions = obj.getPositions().homographyProject(homography) | 333 obj.projectedPositions = obj.getPositions().homographyProject(homography) |
| 334 if undistort: | 334 if undistort: |
| 335 obj.projectedPositions = obj.projectedPositions.newCameraProject(newCameraMatrix) | 335 obj.projectedPositions = obj.projectedPositions.newCameraProject(newCameraMatrix) |
| 342 objDescription += moving.userTypeNames[obj.userType][0].upper() | 342 objDescription += moving.userTypeNames[obj.userType][0].upper() |
| 343 if len(annotations) > 0: # if we loaded annotations, but there is no match | 343 if len(annotations) > 0: # if we loaded annotations, but there is no match |
| 344 if frameNum not in toMatches[obj.getNum()]: | 344 if frameNum not in toMatches[obj.getNum()]: |
| 345 objDescription += " FA" | 345 objDescription += " FA" |
| 346 cv2.putText(img, objDescription, obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvColors[colorType][obj.getNum()]) | 346 cv2.putText(img, objDescription, obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvColors[colorType][obj.getNum()]) |
| 347 objects[:] = [obj for obj in objects if obj.getLastInstant() != frameNum] | 347 if obj.getLastInstant() == frameNum: |
| 348 objects.remove(obj) | |
| 348 # plot object bounding boxes | 349 # plot object bounding boxes |
| 349 if frameNum in boundingBoxes.keys(): | 350 if frameNum in boundingBoxes.keys(): |
| 350 for rect in boundingBoxes[frameNum]: | 351 for rect in boundingBoxes[frameNum]: |
| 351 cv2.rectangle(img, rect[0].asint().astuple(), rect[1].asint().astuple(), cvColors[colorType][obj.getNum()]) | 352 cv2.rectangle(img, rect[0].asint().astuple(), rect[1].asint().astuple(), cvColors[colorType][obj.getNum()]) |
| 352 # plot ground truth | 353 # plot ground truth |
