I have made a script that calibrates using an assymetric pattern imaged by a thermal camera. For some reason my RMS error is around 15. However, undistorting my images does a decent job. I have made a GUI to adjust the blobdetector values for each image manually and return the ret, and corner values on approval.
Am I misunderstanding that the return value for the function should return an error roughly between 0.1 and 1? Or should I use another function to correctly calculate the RMS?
# What images to calibrate
folder = "images/4/"
imageList = glob.glob(folder + "*.*")
print ("Number of images in directory: " + str(len(imageList)))
imgpoints = [] # 2d points in image plane.
objp = np.zeros((gridH * gridW, 3), np.float32)
objp[:, :2] = np.mgrid[0:gridH, 0:gridW].T.reshape(-1, 2)
objpoints = []
my_file = Path(folder + "initialPoints.npy")
if not my_file.is_file():
for image in imageList:
image = cv2.imread(image)
ret, circles = createFindCirclesWindow(image)
if ret:
imgpoints.append(circles)
objpoints.append(objp)
np.save(folder + "initialPoints", imgpoints)
else:
imgpoints = np.load(folder + "initialPoints.npy")
# Match the number of objp for each array if imgpoints
for a in imgpoints:
objpoints.append(objp)
# termination criteria
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
# Calculate camera calibration matrices
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(
objpoints, imgpoints, (imgW, imgH), None, None, flags = cv2.CALIB_FIX_K4+cv2.CALIB_FIX_K5, criteria=criteria)
print (ret)