No corners found in checkerboard pattern using opencv

106 views Asked by At

I have a checkerboard image and I binarize the image to get good gradient across the black and white square, however after I binarize and threshold the image, the algorithm detect no corners. I'm seeking suggestions on how to troubleshoot this issue. This code is a part of camera calibration that I am going to perform using OpenCV and this is new for me.

I use cv2.findChessboardCorners identify corners. here is my code

target_file=[i for i in glob.glob("C:/Users/*.tif")] # 12 images containing checkerboard pattern
    
target_bin =[]
for i in target_file:
    img = plt.imread(i)
    img_bin = img/np.max(img)
    img_threshold = np.where(img_bin<0.45,0,255).astype(np.uint8)
    print(img_bin.dtype,img_threshold.dtype)
    #output of print statement is float64,uint8
    target_bin.append(img_threshold)

    
for img in target_bin:
     print(img.dtype)
    
    # Find the chess board corners
    ret, corners = cv2.findChessboardCorners(img, (5,5), None)
    if ret:
        # Draw the corners on the image
        cv2.drawChessboardCorners(img, (5,5), corners, ret)

        # Display the image with corners
        #plt.imshow(image)
        #plt.axis('off')
        #plt.show()
    else:
        print(f"No chessboard corners found in image: ")

This is my image sample before thresholdingenter image description here

0

There are 0 answers