Reputation: 51
I'm trying to calibrate a camera. I have a very low-contrast image of a checkerboard. I've tried applying Contrast Limited Adaptive Histogram Equalization (CLAHE) to the image, but I'm still struggling to detect the checkerboard.
I've also tried Mrcal with no luck as well.
Here's the image of the checkerboard and the minimum reproducible example.
import cv2
pattern_size=(26, 20)
image = cv2.imread("denoised_image_checkboard_recentered.png")
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
clahe = cv2.createCLAHE(clipLimit=4, tileGridSize=(8,8))
image = clahe.apply(image)
flags = cv2.CALIB_CB_EXHAUSTIVE + cv2.CALIB_CB_ACCURACY
ret, corners = cv2.findChessboardCornersSB(image, pattern_size, flags=flags)
print(ret)
print("---")
print(corners)
Upvotes: 1
Views: 47
Reputation: 54767
This is not an answer to the question, but this shows the way I would attack this problem, and it shows the issues you are facing. This code looks at a vertical slice in the center, and a horizontal slice in the center, and plots it:
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
imgv = Image.open("../Downloads/checkerboard.png")
img = np.array(imgv)
print(img.shape)
midx = img.shape[1]//2
x = img[:,midx]
plt.plot(x)
plt.show()
midy = img.shape[0]//2
y = img[midy,:]
plt.plot(y)
plt.show()
Here's the vertical cross-section:
and here's the horizontal cross-section:
So, what does this show us? This shows us that the lighting in your image is directly above the center and fades out very evenly towards the edges. This is something you could compensate for, but you can see that it's very easy to find the squares in the checkerboard.
The vertical section is not the ideal spot, because it's in a column that starts with a darker square. If we adjusted it left or right a bit, the edge would be much more clear, like the horizontal section.
Upvotes: 1