0
votes

I have read this example from OpenCV regarding calibrating an image using a template pattern of a chessboard. The article suggests that I can use another pattern to calibrate the function:

For stereo applications, these distortions need to be corrected first. To find all these parameters, what we have to do is to provide some sample images of a well defined pattern (eg, chess board). We find some specific points in it ( square corners in chess board). We know its coordinates in real world space and we know its coordinates in image. With these data, some mathematical problem is solved in background to get the distortion coefficients. That is the summary of the whole story. For better results, we need at least 10 test patterns.

but it doesn't go into detail about how to do this.

Are there openCV (or any another library functions) that allow me to do this?

1
you'll have to write the functions to detect the pattern yourself. Afterwards just feed the points to the calibrateCamera function.Micka
Do you have any references I can use to make a pattern detection function?Josh Sharkey
any detector with high accuracy might work. General purpose detectors are for example for QR codes, Aruco Marker, circles, edges, corners, ...Micka
@JoshSharkey, what kind of patterns do you want to detect? Can you give us an example? Camera calibration will work as far as you can match the coordinates of the points in the image frame with the coordinates of the points in the world. You can do it manually or automatically (with the given solutions by OpenCV or you can make your own pattern detector).Darko Lukić

1 Answers

1
votes

Most of the work is already implemented in the OpenCV sample e.g

https://github.com/opencv/opencv/blob/master/samples/cpp/calibration.cpp

Inside you can select directly which pattern you are using

"Usage: calibration\n"
        "     -w=<board_width>         # the number of inner corners per one of board dimension\n"
        "     -h=<board_height>        # the number of inner corners per another board dimension\n"
        "     [-pt=<pattern>]          # the type of pattern: chessboard or circles' grid\n"

When you call this script, just pass the argument -pt=circles

if you are implmenting it on your own it is also quite easy to select

bool found;
switch( pattern )
{
    case CHESSBOARD:
        found = findChessboardCorners( view, boardSize, pointbuf,
            CALIB_CB_ADAPTIVE_THRESH | CALIB_CB_FAST_CHECK | CALIB_CB_NORMALIZE_IMAGE);
        break;
    case CIRCLES_GRID:
        found = findCirclesGrid( view, boardSize, pointbuf );
        break;
    case ASYMMETRIC_CIRCLES_GRID:
        found = findCirclesGrid( view, boardSize, pointbuf, CALIB_CB_ASYMMETRIC_GRID );
        break;
    default:
        return fprintf( stderr, "Unknown pattern type\n" ), -1;
}