Mercurial Hosting > traffic-intelligence
changeset 889:4ea296ee1ae2
work in progress
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 24 Mar 2017 14:20:01 -0400 |
parents | 40994bb43148 |
children | 85bcc758ee5b |
files | scripts/manual-video-analysis.py |
diffstat | 1 files changed, 45 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/manual-video-analysis.py Wed Mar 22 10:50:39 2017 -0400 +++ b/scripts/manual-video-analysis.py Fri Mar 24 14:20:01 2017 -0400 @@ -25,7 +25,42 @@ Spacebar: Go forward one frame l: Skip to frame number q: Quit and end program''') +# configuration of keys and user types (see moving) +userTypeNames = ['unknown', + 'car', + 'pedestrian', + 'motorcycle', + 'bicycle', + 'bus', + 'truck'] +class UserConfiguration(object): + def __init__(self, name, keyNew, keyAddInstant): + self.name = name + self.keyNew = ord(keyNew) + self.keyAddInstant = ord(keyAddInstant) + self.userNum = 0 + self.userInstant = 0 + def isKeyNew(self, k): + return (k == self.keyNew) + + def isKeyAddInstant(self, k): + return (k == self.keyAddInstant) + + def isKey(self, k): + return self.isKeyNew() or self.isKeyAddInstant() + + @staticmethod + def isKey(configurations): + for c in configurations: + if c.isKey(): + return c + return None + +userConfigurations = [UserConfiguration(userTypeNames[1],1,'u','i'), + UserConfiguration(userTypeNames[2],2,'j','k')] + +# start of program cap = cv2.VideoCapture(args.videoFilename) cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, args.firstFrameNum) cv2.namedWindow('Video', cv2.WINDOW_NORMAL) @@ -50,9 +85,18 @@ cv2.imshow('Video',frame) key= cv2.waitKey(0) -#Change the keys to record the vehicle in this section + if key == ord('q'): break + else: + config = UserConfiguration.isKey(userConfigurations) + if config is not None: + if c.isKeyNew(): + pass # increment userNum + elif c.isKeyAddInstant(): + pass # increment userInstant + # print/write + elif key == ord('u') or key == ord('i'): if key == ord('u'): vehNumber += 1