Mercurial > hg > nsaunier > traffic-intelligence
comparison python/cvutils.py @ 226:91197f6a03fe
added goto framenum
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 26 Jun 2012 10:15:11 -0400 |
| parents | 37a434fb848e |
| children | b7612c6d5702 |
comparison
equal
deleted
inserted
replaced
| 225:d4d3b1e8a9f1 | 226:91197f6a03fe |
|---|---|
| 95 def playVideo(filename, firstFrame = 0): | 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 frameNum = 1 |
| 101 capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, firstFrame) | |
| 101 while key!= 113: # 'q' | 102 while key!= 113: # 'q' |
| 102 ret, img = capture.read() | 103 ret, img = capture.read() |
| 103 if ret: | 104 if ret: |
| 105 print('frame {0}'.format(frameNum)) | |
| 106 frameNum+=1 | |
| 104 cv2.imshow('frame', img) | 107 cv2.imshow('frame', img) |
| 105 key = cv2.waitKey(5) | 108 key = cv2.waitKey(5) |
| 106 | 109 |
| 107 def getImagesFromVideo(filename, nImages = 1, saveImage = False): | 110 def getImagesFromVideo(filename, nImages = 1, saveImage = False): |
| 108 '''Returns nImages images from the video sequence''' | 111 '''Returns nImages images from the video sequence''' |
