My code looks like this:
def find_corners(images, camera_name):
imgpoints = []
for idx, img in enumerate(images):
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.001)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Find the chessboard corners
ret, corners = cv2.findChessboardCorners(gray, grid_size, cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FAST_CHECK + cv2.CALIB_CB_NORMALIZE_IMAGE)
if ret:
objpoints.append(objp)
# Refine the corner locations to subpixel accuracy
corners2 = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria)
imgpoints.append(corners2)
# Draw and display the corners
cv2.drawChessboardCorners(img, grid_size, corners2, ret)
cv2.imshow(f'{camera_name} Image {idx + 1}', img)
# Wait for a keypress to move to the next image
print(f"Displaying {camera_name} Image {idx + 1}. Press any key to continue...")
cv2.waitKey(0) # Wait until a key is pressed
cv2.destroyAllWindows()
else:
print(f"Chessboard not found in {camera_name} Image {idx + 1}")
return imgpoints
Grid size:
grid_size = (14, 14) # Inner corners of the chessboard
I have two cameras. One camera3 detects corners just fine, it returns points. The camera2 corner detection does not find any points. Both images were generated using Solidworks and both are pretty much identical except for perspective.
This image calibrated fine:
This image does not:
The order that I try them does not matter. I have re-rendered and resaved the “bad” image and it still does not calibrate.
6