Ask Your Question
0

findChessboardCorners() does not work[SOLVED]

asked 2019-07-15 07:23:18 -0600

Raki gravatar image

updated 2019-07-15 21:50:49 -0600

supra56 gravatar image

I've my checkerboard fixed at a flat surface and I am looking at it with a 4K monocular camera, yet, the code provided does not work. My goal is to find the board's pose w.r.t the camera.

# algorithm parameters
WINDOW_SIZE = 100 # for 4k image
CHECKERBOARD_WIDTH = 6
CHECKERBOARD_HEIGHT = 4
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
objp = np.zeros((CHECKERBOARD_HEIGHT * CHECKERBOARD_WIDTH, 3), np.float32)
objp[:,:2] = np.mgrid[0:CHECKERBOARD_HEIGHT, 0:CHECKERBOARD_WIDTH].T.reshape(-1,2)


 # read the input image
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', required=True,  help='Path to the image')
args = vars(ap.parse_args())
img = cv2.imread(args['image'])

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret, corners = cv2.findChessboardCorners(gray, (CHECKERBOARD_HEIGHT,CHECKERBOARD_WIDTH),None)

it can't continue from the last line, which means it cannot find the squares/corners. Here is my checkerboard

I thought it was not finding it due to the scratches and dirt, so I tried with a better image and it still did not work.

Is this function kinda buggy or somehow sensitive that it takes such a big effort to make it work?

EDIT: Changing the lightning conditions did not help either:

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-07-15 07:42:42 -0600

Raki gravatar image

Okay, got it, the problem was while passing the image.png, I did not use the appropriate path, so the function never even worked.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-07-15 07:23:18 -0600

Seen: 2,188 times

Last updated: Jul 15 '19