Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

findChessboardCorners() does not work

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?

findChessboardCorners() does not work

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

findChessboardCorners() does not work

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