Mercurial Hosting > traffic-intelligence
diff scripts/classify-objects.py @ 901:753a081989e2
factorized some argument handling code
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 22 Jun 2017 12:02:34 -0400 |
parents | 1466a63dd1cf |
children | c69a8defe5c3 |
line wrap: on
line diff
--- a/scripts/classify-objects.py Wed Jun 21 17:49:58 2017 -0400 +++ b/scripts/classify-objects.py Thu Jun 22 12:02:34 2017 -0400 @@ -19,24 +19,11 @@ 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.) args = parser.parse_args() -params = storage.ProcessParameters(args.configFilename) +params, videoFilename, databaseFilename, invHomography, intrinsicCameraMatrix, distortionCoefficients, undistortedImageMultiplication, undistort, firstFrameNum = storage.processVideoArguments(args) + classifierParams = storage.ClassifierParameters(params.classifierFilename) classifierParams.convertToFrames(params.videoFrameRate, 3.6) # conversion from km/h to m/frame -if args.videoFilename is not None: - videoFilename = args.videoFilename -else: - videoFilename = params.videoFilename -if args.databaseFilename is not None: - databaseFilename = args.databaseFilename -else: - databaseFilename = params.databaseFilename - -if params.homography is not None: - invHomography = np.linalg.inv(params.homography) -else: - invHomography = None - if classifierParams.speedAggregationMethod == 'median': speedAggregationFunc = np.median elif classifierParams.speedAggregationMethod == 'mean': @@ -91,8 +78,8 @@ height = int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)) pastObjects = [] -if params.undistort: # setup undistortion - [map1, map2] = cvutils.computeUndistortMaps(width, height, params.undistortedImageMultiplication, params.intrinsicCameraMatrix, params.distortionCoefficients) +if undistort: # setup undistortion + [map1, map2] = cvutils.computeUndistortMaps(width, height, undistortedImageMultiplication, intrinsicCameraMatrix, distortionCoefficients) if capture.isOpened(): ret = True frameNum = timeInterval.first @@ -104,7 +91,7 @@ if ret: if frameNum%50 == 0: print('frame number: {}'.format(frameNum)) - if params.undistort: + if undistort: img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR) currentObjects = [] for obj in objects: