使用openCV函数findChessboardCorners无法检测热图像中的角点

问题描述 投票:0回答:1

正如我在标题中提到的,我无法使用 findChessboardCorners 函数检测这些图像的角点。我的图像是从分辨率为 640x480 的红外摄像机捕获的吗?我的图片对比度足够吗?由于条件有限,无法拍摄更大比例的棋盘?有人可以告诉我出了什么问题吗?

这是我的代码:

CHECKERBOARD = (4, 4)
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

objpoints = []

imgpoints = []


objp = np.zeros((1, CHECKERBOARD[0] * CHECKERBOARD[1], 3), np.float32)
objp[0, :, :2] = np.mgrid[0 : CHECKERBOARD[0], 0 : CHECKERBOARD[1]].T.reshape(-1, 2)
prev_img_shape = None

images = glob.glob("./images2/*.jpg")
for fname in images:
    img = cv2.imread(fname)

    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    # Find the chess board corners
    # If desired number of corners are found in the image then ret = true

    ret, corners = cv2.findChessboardCorners(
        gray,
        CHECKERBOARD,
        cv2.CALIB_CB_ADAPTIVE_THRESH
        + cv2.CALIB_CB_FAST_CHECK
        + cv2.CALIB_CB_NORMALIZE_IMAGE,
    )
    print(ret)
    if ret == True:
        objpoints.append(objp)
        # refining pixel coordinates for given 2d points.
        corners2 = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria)
        imgpoints.append(corners2)

        # Draw and display the corners
        img = cv2.drawChessboardCorners(img, CHECKERBOARD, corners2, ret)

    cv2.imshow("img", gray)
    cv2.waitKey(0)

还有我的一张这样的图片

python opencv camera-calibration
1个回答
0
投票

图像中棋盘尺寸似乎是(2,2)。

© www.soinside.com 2019 - 2024. All rights reserved.