Mercurial Hosting > traffic-intelligence
diff python/cvutils.py @ 393:eaf7765221d9
added code to create bounding boxes and display them (inc scripts)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 26 Jul 2013 02:12:08 -0400 |
parents | 1917db662aa7 |
children | 167f6ec44ec5 |
line wrap: on
line diff
--- a/python/cvutils.py Thu Jul 25 18:59:35 2013 -0400 +++ b/python/cvutils.py Fri Jul 26 02:12:08 2013 -0400 @@ -156,7 +156,7 @@ images.append(img) return images - def displayTrajectories(videoFilename, objects, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1.): + def displayTrajectories(videoFilename, objects, boundingBoxes, homography = None, firstFrameNum = 0, lastFrameNumArg = None, printFrames = True, rescale = 1.): '''Displays the objects overlaid frame by frame over the video ''' capture = cv2.VideoCapture(videoFilename) if capture.isOpened(): @@ -182,6 +182,9 @@ else: obj.projectedPositions = obj.positions draw(img, obj.projectedPositions, cvRed, frameNum-obj.getFirstInstant()) + if frameNum in boundingBoxes.keys(): + for rect in boundingBoxes[frameNum]: + cv2.rectangle(img, rect[0].asint().astuple(), rect[1].asint().astuple(), cvRed) cv2.putText(img, '{0}'.format(obj.num), obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvRed) cvImshow('frame', img, rescale) key = cv2.waitKey()