Main Content

generateWorldPoints

Generate world coordinates for planar pattern keypoints

Since R2021b

Description

example

worldPoints = generateWorldPoints(detectorObj) generates world coordinates for the detected keypoints of the calibration pattern.

worldPoints = generateWorldPoints(detectorObj,varargin) uses the varargin input to parse any additional parameters or options necessary to generate world points. For example, you can provide the parameters or options obtained from the properties pane of your calibrator app.

Examples

collapse all

Use this function template, which includes the use of the generateCheckerboardPoints object function, to generate world points for a checkerboard pattern generator. The function includes both programmatic and app workflows for generating the world (image) points. The function uses name-value arguments for board and square size to set the corresponding fields in the Properties pane of the calibrator app.

function worldPoints = generateWorldPoints(this,varargin) 
    
    if nargin > 1 % Command Line workflow
        parser = inputParser;
        parser.addParameter('SquareSize',25,@checkSquareSize);
        parser.addParameter('BoardSize',this.BoardSize,@checkBoardSize);
        parser.parse(varargin{:});
        
        boardSize = parser.Results.BoardSize;
        squareSize = parser.Results.SquareSize;
    else % Calibrator App workflow
        boardSize = this.BoardSize;
        squareSize = this.SquareSize;
    end
    
    worldPoints = generateCheckerboardPoints(boardSize,squareSize);
    
    %--------------------------------------------------------------
    % Validation functions for command line workflow
    %--------------------------------------------------------------
    function tf = checkSquareSize(squareSize)
        validateattributes(squareSize, {'numeric'}, ...
            {'scalar','positive','finite','nonsparse'},mfilename,'SquareSize');
        tf = true;
    end
    
    %--------------------------------------------------------------
    function tf = checkBoardSize(boardSize)
        validateattributes(boardSize,{'numeric'},...
            {'nonempty','vector','numel',2,'integer','positive','>=', 3},...
            mfilename,'BoardSize'); 
        tf = true;
    end
end

Input Arguments

collapse all

Pattern detector, specified as a single or stereo vision.calibration.PatternDetector object.

Variable number of inputs, specified as a 1-by-N cell array, where N is the number of inputs to the function after detectorObj. For more details about using this input, see varargin.

Output Arguments

collapse all

Image coordinates of detected keypoints in the calibration pattern, returned as an M-by-2 array of x,y coordinates. M is the number of pattern keypoints detected in the calibration images by using thedetectPatternPoints function.

Version History

Introduced in R2021b