问题描述
我一直致力于使用 ChAruCo boards 执行相机校准。
按照代码 here(我的评论版本如下所示),在执行相机校准时似乎只使用其他图像 - 由于抽取器。
这可能是什么原因?除了节省处理能力,这似乎没有必要,因为这一步只执行一次。
def read_chessboards(chessboard_images):
# Charuco base pose estimation.
print("POSE ESTIMATION STARTS:")
# Declare lists to store corner locations and IDs
allCorners = []
allIds = []
decimator = 0
# SUB PIXEL CORNER DETECTION CRITERION
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER,100,0.00001)
# for each of the chessboard images
for im in chessboard_images:
print("=> Processing image {0}".format(im))
frame = cv2.imread(im) # read current image into frame variable
gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) # convert to grayscale
corners,ids,rejectedImgPoints = cv2.aruco.detectMarkers(gray,ARUCO_DICT) # detect markers present in image
# if there are any markers detected
if len(corners) > 0:
# SUB PIXEL DETECTION
for corner in corners:
# refine corner locations
# Todo: check if this works
cv2.cornerSubPix(gray,corner,winSize=(3,3),zeroZone=(-1,-1),criteria=criteria)
# interpolate position of ChArUco board corners.
res2 = cv2.aruco.interpolateCornersCharuco(corners,gray,board)
print(f'Charuco corners at: {res2}')
# if 3+ corners are detected,add to allCorners list for every other image
if res2[1] is not None and res2[2] is not None and len(res2[1]) > 3 and decimator % 1 == 0:
allCorners.append(res2[1])
allIds.append(res2[2])
# why only every other chessboard image?
decimator += 1
imsize = gray.shape
return allCorners,allIds,imsize
解决方法
刚刚意识到 x % 1 总是计算为 0,所以它实际上并没有做任何事情。我想它是作为可选功能包含的 - 如果您将 1 更改为其他数字。