How to calibrate camera with opencv circles grid pattern?

asked 2020-11-04 21:11:06 -0500

Crazy Sage gravatar image

updated 2020-11-04 21:12:09 -0500

I'm trying to calibrate the camera according to openCV tutorial. First I was using chessboard pattern, it was recognized ok, when it was fully in image, but findChessboardCorners function was utterly freezing, when the pattern wasn't completely inside picture, I've found information, that the circles grid algorithm is better, generated target with opencv python script, but it is never found, neither for symmetric nor asymmetric pattern. I need some help, what am I doing wrong?

    cv::Size boardSize( 11, 8 );
    cv::Mat image = cv::imdecode( cv::Mat( 1, data->size(), CV_8UC1, data->data() ), cv::IMREAD_COLOR ); //data is just bytearray filled with jpeg contents from camera
    std::vector< cv::Point2f > pointBuf;
    bool found;
//    int chessBoardFlags = cv::CALIB_CB_ADAPTIVE_THRESH | cv::CALIB_CB_NORMALIZE_IMAGE | cv::CALIB_CB_FAST_CHECK;
    qDebug()<<"Looking for corners";
//    found = findChessboardCorners( image, boardSize, pointBuf, chessBoardFlags);
//    found = findChessboardCorners( image, boardSize, pointBuf, chessBoardFlags, cv::CALIB_CB_ASYMMETRIC_GRID);
    found = findCirclesGrid( image, boardSize, pointBuf );

image description

edit retag flag offensive close merge delete

Comments

A comment about the calibration process.

I've found information, that the circles grid algorithm is better

Calibration board must be completely flat. Glue your calibration sheet on a flat surface, do not hand it like this! You will have bad results.

Eduardo gravatar imageEduardo ( 2020-11-05 01:37:09 -0500 )edit
sturkmen gravatar imagesturkmen ( 2020-11-05 01:59:19 -0500 )edit

@Eduardo I'll try, but is such deformation enough for the target to be completely unrecognizable?

Crazy Sage gravatar imageCrazy Sage ( 2020-11-05 09:22:41 -0500 )edit

@sturkmen I've tried it at first, with cv::CALIB_CB_ASYMMETRIC_GRID flag, but no result

Crazy Sage gravatar imageCrazy Sage ( 2020-11-05 09:23:24 -0500 )edit

use acircles_pattern.png

try

cv::Size boardSize( 4, 11 );
sturkmen gravatar imagesturkmen ( 2020-11-05 10:13:48 -0500 )edit

@sturkmen@Eduardo I tried with acircles_pattern.png, with boardSize( 4, 11) it is only found on heavy downscaled image (around 1MPix instead of base 16MPix for camera). How should it be done? Downscale, find coordinates, multiply them by downscale coefficient, run findCornersSubPix?

Crazy Sage gravatar imageCrazy Sage ( 2020-11-08 08:18:38 -0500 )edit

Perform calibration on downscaled images and scale the intrinsics matrix.

Eduardo gravatar imageEduardo ( 2020-11-13 02:29:02 -0500 )edit