comparison scripts/classify-objects.py @ 935:0e63a918a1ca

updated classify-objects
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 14 Jul 2017 16:30:57 -0400
parents 063d1267585d
children e5970606066f
comparison
equal deleted inserted replaced
934:39691b460fca 935:0e63a918a1ca
72 72
73 capture = cv2.VideoCapture(videoFilename) 73 capture = cv2.VideoCapture(videoFilename)
74 width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) 74 width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH))
75 height = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) 75 height = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT))
76 76
77 if undistort: # setup undistortion 77 #if undistort: # setup undistortion
78 # [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) 78 # [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients)
79 # height, width = map1.shape 79 # height, width = map1.shape
80 newImgSize = (int(round(width*undistortedImageMultiplication)), int(round(height*undistortedImageMultiplication))) 80 # newImgSize = (int(round(width*undistortedImageMultiplication)), int(round(height*undistortedImageMultiplication)))
81 newCameraMatrix = cv2.getDefaultNewCameraMatrix(intrinsicCameraMatrix, newImgSize, True) 81 # newCameraMatrix = cv2.getDefaultNewCameraMatrix(intrinsicCameraMatrix, newImgSize, True)
82 else: 82 #else:
83 newCameraMatrix = None 83 # newCameraMatrix = None
84 84
85 pastObjects = [] 85 pastObjects = []
86 currentObjects = [] 86 currentObjects = []
87 if capture.isOpened(): 87 if capture.isOpened():
88 ret = True 88 ret = True
98 print('frame number: {}'.format(frameNum)) 98 print('frame number: {}'.format(frameNum))
99 #if undistort: 99 #if undistort:
100 # img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) 100 # img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR)
101 for obj in objects: 101 for obj in objects:
102 if obj.getFirstInstant() <= frameNum: # if images are skipped 102 if obj.getFirstInstant() <= frameNum: # if images are skipped
103 obj.initClassifyUserTypeHoGSVM(speedAggregationFunc, pedBikeCarSVM, bikeCarSVM, classifierParams.maxPedestrianSpeed, classifierParams.maxCyclistSpeed, classifierParams.nFramesIgnoreAtEnds, invHomography, newCameraMatrix, distortionCoefficients) 103 obj.initClassifyUserTypeHoGSVM(speedAggregationFunc, pedBikeCarSVM, bikeCarSVM, classifierParams.maxPedestrianSpeed, classifierParams.maxCyclistSpeed, classifierParams.nFramesIgnoreAtEnds, invHomography, intrinsicCameraMatrix, distortionCoefficients)
104 currentObjects.append(obj) 104 currentObjects.append(obj)
105 objects.remove(obj) 105 objects.remove(obj)
106 106
107 for obj in currentObjects: 107 for obj in currentObjects:
108 if obj.getLastInstant() <= frameNum: # if images are skipped 108 if obj.getLastInstant() <= frameNum: # if images are skipped