Mercurial Hosting > traffic-intelligence
comparison python/cvutils.py @ 967:373e8ef6ee25
modified function to access video property
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 05 Dec 2017 16:15:44 -0500 |
parents | 4f32d82ca390 |
children | 5d788d2e8ffc |
comparison
equal
deleted
inserted
replaced
966:40af0f20ee2d | 967:373e8ef6ee25 |
---|---|
188 cv2.cv.CV_CAP_PROP_FRAME_HEIGHT: "heigh", | 188 cv2.cv.CV_CAP_PROP_FRAME_HEIGHT: "heigh", |
189 cv2.cv.CV_CAP_PROP_FRAME_WIDTH: "width", | 189 cv2.cv.CV_CAP_PROP_FRAME_WIDTH: "width", |
190 cv2.cv.CV_CAP_PROP_RECTIFICATION: "rectification", | 190 cv2.cv.CV_CAP_PROP_RECTIFICATION: "rectification", |
191 cv2.cv.CV_CAP_PROP_SATURATION: "saturation"} | 191 cv2.cv.CV_CAP_PROP_SATURATION: "saturation"} |
192 capture = cv2.VideoCapture(filename) | 192 capture = cv2.VideoCapture(filename) |
193 videoProperties = {} | |
193 if capture.isOpened(): | 194 if capture.isOpened(): |
194 for cvprop in [#cv2.cv.CV_CAP_PROP_BRIGHTNESS | 195 for cvprop in [#cv2.cv.CV_CAP_PROP_BRIGHTNESS |
195 #cv2.cv.CV_CAP_PROP_CONTRAST | 196 #cv2.cv.CV_CAP_PROP_CONTRAST |
196 #cv2.cv.CV_CAP_PROP_CONVERT_RGB | 197 #cv2.cv.CV_CAP_PROP_CONVERT_RGB |
197 #cv2.cv.CV_CAP_PROP_EXPOSURE | 198 #cv2.cv.CV_CAP_PROP_EXPOSURE |
211 #cv2.cv.CV_CAP_PROP_SATURATION | 212 #cv2.cv.CV_CAP_PROP_SATURATION |
212 ]: | 213 ]: |
213 prop = capture.get(cvprop) | 214 prop = capture.get(cvprop) |
214 if cvprop == cv2.cv.CV_CAP_PROP_FOURCC and prop > 0: | 215 if cvprop == cv2.cv.CV_CAP_PROP_FOURCC and prop > 0: |
215 prop = int2FOURCC(int(prop)) | 216 prop = int2FOURCC(int(prop)) |
216 print('Video {}: {}'.format(cvPropertyNames[cvprop], prop)) | 217 videoProperties[cvPropertyNames[cvprop]] = prop |
217 else: | 218 else: |
218 print('Video capture for {} failed'.format(filename)) | 219 print('Video capture for {} failed'.format(filename)) |
220 return videoProperties | |
219 | 221 |
220 def getImagesFromVideo(videoFilename, firstFrameNum = 0, lastFrameNum = 1, step = 1, saveImage = False, outputPrefix = 'image'): | 222 def getImagesFromVideo(videoFilename, firstFrameNum = 0, lastFrameNum = 1, step = 1, saveImage = False, outputPrefix = 'image'): |
221 '''Returns nFrames images from the video sequence''' | 223 '''Returns nFrames images from the video sequence''' |
222 images = [] | 224 images = [] |
223 capture = cv2.VideoCapture(videoFilename) | 225 capture = cv2.VideoCapture(videoFilename) |