Mercurial Hosting > traffic-intelligence
changeset 223:c31722fcc9de
minor modifications for integer drawing in OpenCV
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 26 Jun 2012 03:29:57 -0400 |
parents | 426321b46e44 |
children | 37a434fb848e |
files | python/cvutils.py python/moving.py |
diffstat | 2 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/python/cvutils.py Tue Jun 26 02:08:01 2012 -0400 +++ b/python/cvutils.py Tue Jun 26 03:29:57 2012 -0400 @@ -90,7 +90,7 @@ if lastCoordinate != None and lastCoordinate >=0: last = min(positions.length()-1, lastCoordinate) for i in range(0, last-1): - cv2.line(img, positions[i].astuple(), positions[i+1].astuple(), color) + cv2.line(img, positions[i].asint().astuple(), positions[i+1].asint().astuple(), color) def playVideo(filename): '''Plays the video''' @@ -142,7 +142,7 @@ else: obj.projectedPositions = obj.positions draw(img, obj.projectedPositions, cvRed, frameNum-obj.getFirstInstant()) - cv2.putText(img, '{0}'.format(obj.num), obj.projectedPositions[frameNum-obj.getFirstInstant()].astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvRed) + cv2.putText(img, '{0}'.format(obj.num), obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvRed) cv2.imshow('frame', img) key = cv2.waitKey(50) frameNum += 1
--- a/python/moving.py Tue Jun 26 02:08:01 2012 -0400 +++ b/python/moving.py Tue Jun 26 03:29:57 2012 -0400 @@ -159,6 +159,9 @@ def astuple(self): return (self.x, self.y) + def asint(self): + return Point(int(self.x), int(self.y)) + def project(self, homography): from numpy.core.multiarray import array projected = cvutils.projectArray(homography, array([[self.x], [self.y]]))