Mercurial Hosting > traffic-intelligence
diff scripts/manual-video-analysis.py @ 998:933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 27 May 2018 23:22:48 -0400 |
parents | ab3a4cb524a9 |
children | 234e2228fd30 |
line wrap: on
line diff
--- a/scripts/manual-video-analysis.py Fri May 25 18:15:18 2018 -0400 +++ b/scripts/manual-video-analysis.py Sun May 27 23:22:48 2018 -0400 @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import sys, argparse, cv2, numpy as np @@ -22,7 +22,7 @@ Press x to go back 10 frames Press spacebar to go forward one frame Press l to skip to frame number -Press Enter to finish inputting user characteristics (if any in pop up window) +Press s to finish inputting user characteristics (if any in pop up window) Press q to quit and end program''') # configuration of keys and user types (see moving) userTypeNames = ['unknown', @@ -82,8 +82,8 @@ # start of program cap = cv2.VideoCapture(args.videoFilename) -cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, args.firstFrameNum) -fps = cap.get(cv2.cv.CV_CAP_PROP_FPS) +cap.set(cv2.CAP_PROP_POS_FRAMES, args.firstFrameNum) +fps = cap.get(cv2.CAP_PROP_FPS) print('Video at {} frames/s'.format(fps)) cv2.namedWindow('Video', cv2.WINDOW_NORMAL) @@ -102,7 +102,7 @@ while(cap.isOpened()): ret, frame = cap.read() - frameNum = int(cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)) + frameNum = int(cap.get(cv2.CAP_PROP_POS_FRAMES)) cv2.putText(frame, str(frameNum), (1,20), cv2.FONT_HERSHEY_PLAIN, 1, (255, 0,0)) cv2.imshow('Video',frame) @@ -123,7 +123,7 @@ attributeNum = 0 while key2 != ord('s'): attrImg = 255*np.ones((20*args.nAttributes, 20, 3)) - for i in xrange(args.nAttributes): + for i in range(args.nAttributes): if i == (attributeNum%args.nAttributes): cv2.putText(attrImg, str(config.attributes[i]), (1,20*(i+1)), cv2.FONT_HERSHEY_PLAIN, 1, (0, 0, 255)) else: @@ -153,8 +153,8 @@ elif key == ord('c'): cap.set(1,frameNum-100) elif key == ord('l'): - frameNum = int(raw_input("Please enter the frame number you would like to skip to\n")) - cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES,frameNum) + frameNum = int(input("Please enter the frame number you would like to skip to\n")) + cap.set(cv2.CAP_PROP_POS_FRAMES,frameNum) out.close() cap.release()