Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 224:37a434fb848e
added goto frame
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 26 Jun 2012 03:36:55 -0400 |
parents | c31722fcc9de |
children | 91197f6a03fe |
comparison
equal
deleted
inserted
replaced
223:c31722fcc9de | 224:37a434fb848e |
---|---|
90 if lastCoordinate != None and lastCoordinate >=0: | 90 if lastCoordinate != None and lastCoordinate >=0: |
91 last = min(positions.length()-1, lastCoordinate) | 91 last = min(positions.length()-1, lastCoordinate) |
92 for i in range(0, last-1): | 92 for i in range(0, last-1): |
93 cv2.line(img, positions[i].asint().astuple(), positions[i+1].asint().astuple(), color) | 93 cv2.line(img, positions[i].asint().astuple(), positions[i+1].asint().astuple(), color) |
94 | 94 |
95 def playVideo(filename): | 95 def playVideo(filename, firstFrame = 0): |
96 '''Plays the video''' | 96 '''Plays the video''' |
97 capture = cv2.VideoCapture(filename) | 97 capture = cv2.VideoCapture(filename) |
98 if capture.isOpened(): | 98 if capture.isOpened(): |
99 key = -1 | 99 key = -1 |
100 capture.set(CV_CAP_PROP_POS_FRAMES, firstFrame) | |
100 while key!= 113: # 'q' | 101 while key!= 113: # 'q' |
101 ret, img = capture.read() | 102 ret, img = capture.read() |
102 if ret: | 103 if ret: |
103 cv2.imshow('frame', img) | 104 cv2.imshow('frame', img) |
104 key = cv2.waitKey(5) | 105 key = cv2.waitKey(5) |