Mercurial Hosting > traffic-intelligence
comparison scripts/classify-objects.py @ 684:6d2ece4aed7c dev
bug forgot to svae objects
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 05 Jun 2015 13:26:51 +0200 |
parents | f3a0b652b590 |
children | 94b291a5f933 |
comparison
equal
deleted
inserted
replaced
683:f3a0b652b590 | 684:6d2ece4aed7c |
---|---|
70 | 70 |
71 capture = cv2.VideoCapture(params.videoFilename) | 71 capture = cv2.VideoCapture(params.videoFilename) |
72 width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) | 72 width = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)) |
73 height = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) | 73 height = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) |
74 | 74 |
75 pastObjects = [] | |
75 if params.undistort: # setup undistortion | 76 if params.undistort: # setup undistortion |
76 [map1, map2] = computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) | 77 [map1, map2] = computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) |
77 if capture.isOpened(): | 78 if capture.isOpened(): |
78 ret = True | 79 ret = True |
79 frameNum = timeInterval.first | 80 frameNum = timeInterval.first |
85 if ret: | 86 if ret: |
86 if frameNum%50 == 0: | 87 if frameNum%50 == 0: |
87 print('frame number: {}'.format(frameNum)) | 88 print('frame number: {}'.format(frameNum)) |
88 currentObjects = [] | 89 currentObjects = [] |
89 for obj in objects: | 90 for obj in objects: |
90 if obj.getLastFrameNum() < frameNum: | 91 if obj.getLastInstant() < frameNum: |
91 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities) | 92 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities) |
93 pastObjects.append(obj) | |
92 else: | 94 else: |
93 currentObjects.append(obj) | 95 currentObjects.append(obj) |
94 objects = currentObjects | 96 objects = currentObjects |
95 if params.undistort: | 97 if params.undistort: |
96 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) | 98 img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) |
101 obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, invHomography, width, height, 0.2, 0.2, 800) # px, py, pixelThreshold | 103 obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, invHomography, width, height, 0.2, 0.2, 800) # px, py, pixelThreshold |
102 frameNum += 1 | 104 frameNum += 1 |
103 | 105 |
104 for obj in objects: | 106 for obj in objects: |
105 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities) | 107 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = params.minSpeedEquiprobable, speedProbabilities = speedProbabilities) |
108 pastObjects.append(obj) | |
109 print('Saving user types') | |
110 storage.setRoadUserTypes(params.databaseFilename, pastObjects) |