Mercurial Hosting > traffic-intelligence
changeset 435:17185fe77316
added error messages if video not opened
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 02 Dec 2013 16:39:50 -0500 |
parents | 9a714f32fc9f |
children | b64ff7fe7b45 |
files | python/cvutils.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/python/cvutils.py Sat Nov 30 18:03:35 2013 -0500 +++ b/python/cvutils.py Mon Dec 02 16:39:50 2013 -0500 @@ -134,6 +134,8 @@ cvImshow('frame', img, rescale) key = cv2.waitKey(wait) cv2.destroyAllWindows() + else: + print('Video capture for {} failed'.format(videoFilename)) def getImagesFromVideo(videoFilename, firstFrameNum = 0, nFrames = 1, saveImage = False, outputPrefix = 'image'): '''Returns nFrames images from the video sequence''' @@ -160,7 +162,7 @@ imgNum +=1 capture.release() else: - print('Video capture failed') + print('Video capture for {} failed'.format(videoFilename)) return images def getFPS(videoFilename): @@ -170,7 +172,7 @@ capture.release() return fps else: - print 'Cannot load file ' + videoFilename + print('Video capture for {} failed'.format(videoFilename)) return None def imageBox(img, obj, frameNum, homography, width, height, px = 0.2, py = 0.2, pixelThreshold = 800): @@ -246,6 +248,8 @@ cv2.imwrite('image.png', img) frameNum += 1 cv2.destroyAllWindows() + else: + print 'Cannot load file ' + videoFilename def computeHomographyFromPDTV(cameraFilename, method=0, ransacReprojThreshold=3.0): '''Returns the homography matrix at ground level from PDTV format