Mercurial Hosting > traffic-intelligence
changeset 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 | 40af0f20ee2d |
children | 32a34a143c27 |
files | python/cvutils.py scripts/info-video.py |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/python/cvutils.py Tue Dec 05 16:11:49 2017 -0500 +++ b/python/cvutils.py Tue Dec 05 16:15:44 2017 -0500 @@ -190,6 +190,7 @@ cv2.cv.CV_CAP_PROP_RECTIFICATION: "rectification", cv2.cv.CV_CAP_PROP_SATURATION: "saturation"} capture = cv2.VideoCapture(filename) + videoProperties = {} if capture.isOpened(): for cvprop in [#cv2.cv.CV_CAP_PROP_BRIGHTNESS #cv2.cv.CV_CAP_PROP_CONTRAST @@ -213,9 +214,10 @@ prop = capture.get(cvprop) if cvprop == cv2.cv.CV_CAP_PROP_FOURCC and prop > 0: prop = int2FOURCC(int(prop)) - print('Video {}: {}'.format(cvPropertyNames[cvprop], prop)) + videoProperties[cvPropertyNames[cvprop]] = prop else: print('Video capture for {} failed'.format(filename)) + return videoProperties def getImagesFromVideo(videoFilename, firstFrameNum = 0, lastFrameNum = 1, step = 1, saveImage = False, outputPrefix = 'image'): '''Returns nFrames images from the video sequence'''
--- a/scripts/info-video.py Tue Dec 05 16:11:49 2017 -0500 +++ b/scripts/info-video.py Tue Dec 05 16:15:44 2017 -0500 @@ -9,4 +9,6 @@ args = parser.parse_args() -cvutils.infoVideo(args.videoFilename) +videoProperties = cvutils.infoVideo(args.videoFilename) +for k,v in videoProperties.iteritems(): + print('Video {}: {}'.format(k, v))