def __init__(self, camera_config, target_config):
        target_params = target_config.getTargetParams()
        target_type = target_config.getTargetType()

        # Set up target
        if target_type == 'checkerboard':
            grid = acv.GridCalibrationTargetCheckerboard(
                target_params['targetRows'], target_params['targetCols'],
                target_params['rowSpacingMeters'],
                target_params['colSpacingMeters'])

        elif target_type == 'circlegrid':
            options = acv.CirclegridOptions()
            options.useAsymmetricCirclegrid = target_params['asymmetricGrid']

            grid = acv.GridCalibrationTargetCirclegrid(
                target_params['targetRows'], target_params['targetCols'],
                target_params['spacingMeters'], options)

        elif target_type == 'aprilgrid':
            grid = acv_april.GridCalibrationTargetAprilgrid(
                target_params['tagRows'], target_params['tagCols'],
                target_params['tagSize'], target_params['tagSpacing'])

        else:
            raise RuntimeError("Unknown calibration target.")

        # Setup detector
        options = acv.GridDetectorOptions()
        options.filterCornerOutliers = True
        self.detector = acv.GridDetector(camera_config.geometry, grid, options)
예제 #2
0
    def __init__(self,
                 targetConfig,
                 cameraGeometry,
                 gridpoints=None,
                 showCorners=False,
                 showReproj=False,
                 showOneStep=False):
        self.targetConfig = targetConfig

        #initialize the calibration target
        targetParams = targetConfig.getTargetParams()
        targetType = targetConfig.getTargetType()

        if targetType == 'checkerboard':
            options = acv.CheckerboardOptions()
            options.filterQuads = True
            options.normalizeImage = True
            options.useAdaptiveThreshold = True
            options.performFastCheck = False
            options.windowWidth = 5
            options.showExtractionVideo = showCorners

            self.grid = acv.GridCalibrationTargetCheckerboard(
                targetParams['targetRows'], targetParams['targetCols'],
                targetParams['rowSpacingMeters'],
                targetParams['colSpacingMeters'], options)
        elif targetType == 'circlegrid':
            options = acv.CirclegridOptions()
            options.showExtractionVideo = showCorners
            options.useAsymmetricCirclegrid = targetParams['asymmetricGrid']

            self.grid = acv.GridCalibrationTargetCirclegrid(
                targetParams['targetRows'], targetParams['targetCols'],
                targetParams['spacingMeters'], options)

        elif targetType == 'aprilgrid':
            options = acv_april.AprilgridOptions()
            #enforce more than one row --> pnp solution can be bad if all points are almost on a line...
            options.minTagsForValidObs = int(
                np.max([targetParams['tagRows'], targetParams['tagCols']]) + 1)
            options.showExtractionVideo = showCorners

            self.grid = acv_april.GridCalibrationTargetAprilgrid(
                targetParams['tagRows'], targetParams['tagCols'],
                targetParams['tagSize'], targetParams['tagSpacing'], options)
        elif targetType == 'general':
            self.grid = acv.GridCalibrationTargetGeneral(
                targetParams['tagRows'], targetParams['tagCols'])
            self.grid.setPoints(gridpoints)
        else:
            RuntimeError('Unknown calibration target type!')

        options = acv.GridDetectorOptions()
        options.imageStepping = showOneStep
        options.plotCornerReprojection = showReproj
        options.filterCornerOutliers = False

        self.detector = acv.GridDetector(cameraGeometry, self.grid, options)
예제 #3
0
    def setupCalibrationTarget(self,
                               targetConfig,
                               showExtraction=False,
                               showReproj=False,
                               imageStepping=False):

        #load the calibration target configuration
        targetParams = targetConfig.getTargetParams()
        targetType = targetConfig.getTargetType()

        if targetType == 'checkerboard':
            options = acv.CheckerboardOptions()
            options.showExtractionVideo = showExtraction
            grid = acv.GridCalibrationTargetCheckerboard(
                targetParams['targetRows'], targetParams['targetCols'],
                targetParams['rowSpacingMeters'],
                targetParams['colSpacingMeters'], options)
        elif targetType == 'circlegrid':
            options = acv.CirclegridOptions()
            options.showExtractionVideo = showExtraction
            options.useAsymmetricCirclegrid = targetParams['asymmetricGrid']
            grid = acv.GridCalibrationTargetCirclegrid(
                targetParams['targetRows'], targetParams['targetCols'],
                targetParams['spacingMeters'], options)
        elif targetType == 'aprilgrid':
            options = acv_april.AprilgridOptions()
            options.showExtractionVideo = showExtraction
            options.minTagsForValidObs = int(
                np.max([targetParams['tagRows'], targetParams['tagCols']]) + 1)

            grid = acv_april.GridCalibrationTargetAprilgrid(
                targetParams['tagRows'], targetParams['tagCols'],
                targetParams['tagSize'], targetParams['tagSpacing'], options)
        else:
            raise RuntimeError("Unknown calibration target.")

        options = acv.GridDetectorOptions()
        options.imageStepping = imageStepping
        options.plotCornerReprojection = showReproj
        options.filterCornerOutliers = True
        #options.filterCornerSigmaThreshold = 2.0
        #options.filterCornerMinReprojError = 0.2
        self.detector = acv.GridDetector(self.camera.geometry, grid, options)
예제 #4
0
    def __init__(self,
                 targetConfig,
                 cameraGeometry,
                 showCorners=False,
                 showReproj=False,
                 showOneStep=False):
        self.targetConfig = targetConfig

        #initialize the calibration target
        targetParams = targetConfig.getTargetParams()
        targetType = targetConfig.getTargetType()

        if targetType == 'checkerboard':
            options = acv.CheckerboardOptions()
            options.filterQuads = True
            options.normalizeImage = True
            options.useAdaptiveThreshold = True
            options.performFastCheck = False
            options.windowWidth = 5
            options.showExtractionVideo = showCorners

            self.grid = acv.GridCalibrationTargetCheckerboard(
                targetParams['targetRows'], targetParams['targetCols'],
                targetParams['rowSpacingMeters'],
                targetParams['colSpacingMeters'], options)
        elif targetType == 'circlegrid':
            options = acv.CirclegridOptions()
            options.showExtractionVideo = showCorners
            options.useAsymmetricCirclegrid = targetParams['asymmetricGrid']

            self.grid = acv.GridCalibrationTargetCirclegrid(
                targetParams['targetRows'], targetParams['targetCols'],
                targetParams['spacingMeters'], options)

        elif targetType == 'aprilgrid':
            options = acv_april.AprilgridOptions()
            #enforce more than one row --> pnp solution can be bad if all points are almost on a line...
            options.minTagsForValidObs = int(
                np.max([targetParams['tagRows'], targetParams['tagCols']]) + 1)
            options.showExtractionVideo = showCorners

            self.grid = acv_april.GridCalibrationTargetAprilgrid(
                targetParams['tagRows'], targetParams['tagCols'],
                targetParams['tagSize'], targetParams['tagSpacing'], options)
        elif targetType == 'assymetric_aprilgrid':
            options = acv_april.AprilgridOptions()
            #enforce more than one row --> pnp solution can be bad if all points are almost on a line...
            options.minTagsForValidObs = 1
            options.showExtractionVideo = showCorners
            #options.maxSubpixDisplacement2 = 2
            #options.doSubpixRefinement = False
            vectorTags = []
            for tag in targetParams['tags']:
                structTag = acv_april.TargetPoint()
                structTag.x = tag["pos"][0]
                structTag.y = tag["pos"][1]
                structTag.size = tag["size"]
                vectorTags.append(structTag)

            self.grid = acv_april.GridCalibrationTargetAssymetricAprilgrid(
                vectorTags, options)
        else:
            RuntimeError('Unknown calibration target type!')

        options = acv.GridDetectorOptions()
        options.imageStepping = showOneStep
        options.plotCornerReprojection = showReproj
        options.filterCornerOutliers = False

        self.detector = acv.GridDetector(cameraGeometry, self.grid, options)