admin管理员组

文章数量:1356582

I tried using opencv-python to calibrate a charuco marker board. My code successfully detected the ArUco markers, but the interpolation calculation for corner points always returned (0, None, None). Attempting to set setLegacyPattern(True) or False still didn't work.

Here is my code

CHARUCOBOARD_ROWCOUNT = 11 
CHARUCOBOARD_COLCOUNT = 8 
SQUARE_LENGTH = 0.022
MARKER_LENGTH = 0.016
ARUCO_DICT = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_1000) 

charuco_board = cv2.aruco.CharucoBoard(
    (CHARUCOBOARD_COLCOUNT, CHARUCOBOARD_ROWCOUNT), SQUARE_LENGTH, MARKER_LENGTH, ARUCO_DICT
)

charuco_board.setLegacyPattern(True)

image_files = glob.glob('calibration_images_aruco/*.jpg')  
all_corners = []  
all_ids = [] 
image_size = None  

for image_file in image_files:
    image = cv2.imread(image_file)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    corners, ids, rejected = cv2.aruco.detectMarkers(gray, ARUCO_DICT)
    cv2.aruco.drawDetectedMarkers(image, corners, ids)

    if len(corners) > 0:
        criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.00001)
        for corner in corners:
            cv2.cornerSubPix(gray, corner, winSize=(3, 3), zeroZone=(-1, -1), criteria=criteria)

        ret, charuco_corners, charuco_ids = cv2.aruco.interpolateCornersCharuco(
            corners, ids, gray, charuco_board
        )
        print(ret,charuco_corners,charuco_ids)

        if ret > 0:
            all_corners.append(charuco_corners)
            all_ids.append(charuco_ids)
            if image_size is None:
                image_size = gray.shape[::-1]
    cv2.imshow("Image", image)

run it and shows

0 None None
0 None None
...

here is my env

python 3.10.16
opencv-contrib-python                4.10.0.84
opencv-python                        4.10.0.84

here is my it images(1920x1080)

i also tried (640x480),(1080x720),but get the same results

origional image

image with conermarkers

本文标签: pythoninterpolateCornersCharuco cant find conrnersStack Overflow