Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/classify-objects.py @ 962:64259b9885bf
verbose option to print classification information (more to add)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 06 Nov 2017 21:25:41 -0500 |
| parents | 053484e08947 |
| children | e8eabef7857c |
comparison
equal
deleted
inserted
replaced
| 961:ec1682ed999f | 962:64259b9885bf |
|---|---|
| 16 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (overrides the configuration file)') | 16 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file (overrides the configuration file)') |
| 17 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to classify', type = int, default = None) | 17 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to classify', type = int, default = None) |
| 18 parser.add_argument('--start-frame0', dest = 'startFrame0', help = 'starts with first frame for videos with index problem where frames cannot be reached', action = 'store_true') | 18 parser.add_argument('--start-frame0', dest = 'startFrame0', help = 'starts with first frame for videos with index problem where frames cannot be reached', action = 'store_true') |
| 19 parser.add_argument('--plot-speed-distributions', dest = 'plotSpeedDistribution', help = 'simply plots the distributions used for each user type', action = 'store_true') | 19 parser.add_argument('--plot-speed-distributions', dest = 'plotSpeedDistribution', help = 'simply plots the distributions used for each user type', action = 'store_true') |
| 20 parser.add_argument('--max-speed-distribution-plot', dest = 'maxSpeedDistributionPlot', help = 'if plotting the user distributions, the maximum speed to display (km/h)', type = float, default = 50.) | 20 parser.add_argument('--max-speed-distribution-plot', dest = 'maxSpeedDistributionPlot', help = 'if plotting the user distributions, the maximum speed to display (km/h)', type = float, default = 50.) |
| 21 parser.add_argument('--verbose', dest = 'verbose', help = 'verbose information', action = 'store_true') | |
| 21 | 22 |
| 22 args = parser.parse_args() | 23 args = parser.parse_args() |
| 23 params, videoFilename, databaseFilename, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum = storage.processVideoArguments(args) | 24 params, videoFilename, databaseFilename, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum = storage.processVideoArguments(args) |
| 24 classifierParams = storage.ClassifierParameters(params.classifierFilename) | 25 classifierParams = storage.ClassifierParameters(params.classifierFilename) |
| 25 classifierParams.convertToFrames(params.videoFrameRate, 3.6) # conversion from km/h to m/frame | 26 classifierParams.convertToFrames(params.videoFrameRate, 3.6) # conversion from km/h to m/frame |
| 109 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown) | 110 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown) |
| 110 pastObjects.append(obj) | 111 pastObjects.append(obj) |
| 111 currentObjects.remove(obj) | 112 currentObjects.remove(obj) |
| 112 else: | 113 else: |
| 113 obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels, classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogNCellsPerBlock, classifierParams.hogBlockNorm) | 114 obj.classifyUserTypeHoGSVMAtInstant(img, frameNum, width, height, classifierParams.percentIncreaseCrop, classifierParams.percentIncreaseCrop, classifierParams.minNPixels, classifierParams.hogRescaleSize, classifierParams.hogNOrientations, classifierParams.hogNPixelsPerCell, classifierParams.hogNCellsPerBlock, classifierParams.hogBlockNorm) |
| 115 if args.verbose: | |
| 116 print('obj {}@{}: {}'.format(obj.getNum(), frameNum, moving.userTypeNames[obj.userTypes[frameNum]])) | |
| 114 frameNum += 1 | 117 frameNum += 1 |
| 115 | 118 |
| 116 for obj in currentObjects: | 119 for obj in currentObjects: |
| 117 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown) | 120 obj.classifyUserTypeHoGSVM(minSpeedEquiprobable = classifierParams.minSpeedEquiprobable, speedProbabilities = speedProbabilities, maxPercentUnknown = classifierParams.maxPercentUnknown) |
| 118 pastObjects.append(obj) | 121 pastObjects.append(obj) |
