Main Content

detectPatternPoints

Detect calibration pattern keypoints in images

Since R2021b

Description

[imagePoints,imagesUsed] = detectPatternPoints(detectorObj,imageFileNames) detects the calibration pattern keypoints in the image files, specified by imageFileNames. The function also indicates in which of the images it detects the calibration pattern.

example

[imagePoints,pairsUsed] = detectPatternPoints(detectorObj,imageFileNames1,imageFileNames2) detects the calibration pattern keypoints in the stereo pairs of image files specified in imageFileNames1 and imageFileNames2. The function also indicates in which of the image pairs it detects the calibration pattern.

[___] = detectPatternPoints(___,varargin) parses any parameters or options needed for detection. For example, you can provide the parameters or options obtained from the properties panel of your calibrator app while using it from the command line.

Examples

collapse all

Use this function template, which includes the use of the detectPatternPoints object function, to detect the keypoints of a calibration pattern. The function includes both programmatic and app workflows for detecting the points.

function [imagePoints,imagesUsed] = detectPatternPoints(this,imageFileNames,varargin) 
    parser = inputParser;
    parser.addParameter('HighDistortion',false,@checkHighDistortion);
    parser.parse(varargin{:});
    highDistortion = parser.Results.HighDistortion;
    
    % Use 'IsDistortionHigh' member value when the default value is
    % being used for HighDistortion
    if ismember('HighDistortion',parser.UsingDefaults)
       highDistortion = this.IsDistortionHigh;  
    end
    
    [imagePoints,boardSize,imagesUsed] = detectCheckerboardPoints( ...
        imageFileNames,HighDistortion=highDistortion);
    
    this.BoardSize = boardSize;
    
    %--------------------------------------------------------------
    function tf = checkHighDistortion(highDistortion)
        validateattributes(highDistortion,{'logical','numeric'}, ...
            {'scalar','binary'},mfilename,'HighDistortion');
        tf = true;
    end
end

Input Arguments

collapse all

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

Image file names, specified as a cell array of character vectors or a vector of strings.

Stereo image file names for camera one, specified as a cell array of character vectors or an array of strings.

Stereo image file names for camera two, specified as a cell array of character vectors or an array of strings.

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

Output Arguments

collapse all

Image x-y coordinates of detected pattern keypoints, returned as an M-by-2-by-numImages array for single camera calibration or an M-by-2-by-numPairs-by-2 array for stereo camera calibration. numImages is the number of images in which a circle grid is detected. numPairs is the number of image pairs in which a circle grid is detected. For stereo images, imagePoints(:,:,:,1) returns the pattern keypoints from the first set of images, and imagePoints(:,:,:,2) returns the pattern keypoints from the second set of images. If the function cannot detect the complete pattern, then it returns a partially detected pattern with [NaN,NaN] for those x-y coordinates that could not be detected.

Pattern detection flag, returned as a logical vector. A value of true for an element of the imagesUsed vector indicates that the function has detected the pattern in the corresponding image.

Stereo pair pattern detection flag, returned as a logical vector. A value of true for an element of the pairsUsed vector indicates that the function has detected the pattern in the corresponding image pair.

Version History

Introduced in R2021b