Sabrine
Sabrine

Reputation: 3

camera calibration using python

i am trying to calibrate my tow webcams using the chessboard method but each time i excute the code source which is provided in opencv samples i got this message:

processing ../cpp\img1.jpg... chessboard not found
processing ../cpp\img2.jpg... chessboard not found
processing ../cpp\img3.jpg... chessboard not found
processing ../cpp\img4.jpg... chessboard not found
processing ../cpp\img5.jpg... chessboard not found

here is the img1 https://i.sstatic.net/04b4U.jpg

okay,the code is the one in opencv samples here it is the part of cv2.FindChessboard()

 for fn in img_names:
    print 'processing %s...' % fn,
    img = cv2.imread(fn, 0)
    h, w = img.shape[:2]
    found, corners = cv2.findChessboardCorners(img, pattern_size)
    if found:
        term = ( cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_COUNT, 30, 0.1 )
        cv2.cornerSubPix(img, corners, (5, 5), (-1, -1), term)
    if debug_dir:
        vis = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
        cv2.drawChessboardCorners(vis, pattern_size, corners, found)
        path, name, ext = splitfn(fn)
        cv2.imwrite('%s/%s_chess.bmp' % (debug_dir, name), vis)
    if not found:
        print 'chessboard not found'
        continue
    img_points.append(corners.reshape(-1, 2))
    obj_points.append(pattern_points)

    print 'ok'

Upvotes: 0

Views: 2557

Answers (1)

BConic
BConic

Reputation: 8990

Assuming your code is OK, you might have a problem with your chessboard. Have a look at the documentation on function findChessboardCorners (link), at the end there is a note saying the following:

The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails.

If you look at the images provided in this calibration tutorial, there is a lot more white space around the chessboard and this is important:

enter image description here

Also, it might be an impression, but it seems your outer squares do not have the same size than the others, which could also be important.

Upvotes: 1

Related Questions