Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cv2.aruco.interpolateCornersCharuco is deprecated #979

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions camera_calibration/src/camera_calibration/calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ def __init__(self, pattern="chessboard", n_cols = 0, n_rows = 0, dim = 0.0, mark
"7x7_100" : cv2.aruco.DICT_7X7_100,
"7x7_250" : cv2.aruco.DICT_7X7_250,
"7x7_1000" : cv2.aruco.DICT_7X7_1000}[aruco_dict])
self.charuco_board = cv2.aruco.CharucoBoard_create(self.n_cols, self.n_rows, self.dim, self.marker_size,
self.aruco_dict)
if cv2.__version__ >= '4.8.0':
self.charuco_board = cv2.aruco.CharucoBoard((self.n_cols, self.n_rows), self.dim, self.marker_size,
self.aruco_dict)
else:
self.charuco_board = cv2.aruco.CharucoBoard_create(self.n_cols, self.n_rows, self.dim, self.marker_size,
self.aruco_dict)


# Make all private!!!!!
def lmin(seq1, seq2):
Expand Down Expand Up @@ -268,10 +273,17 @@ def _get_charuco_corners(img, board, refine):
else:
mono = img

marker_corners, marker_ids, _ = cv2.aruco.detectMarkers(img, board.aruco_dict)
if len(marker_corners) == 0:
return (False, None, None)
_, square_corners, ids = cv2.aruco.interpolateCornersCharuco(marker_corners, marker_ids, img, board.charuco_board)

if cv2.__version__ >= '4.8.0':
charucodetector = cv2.aruco.CharucoDetector(board.charuco_board)
square_corners, ids, marker_corners, marker_ids = charucodetector.detectBoard(mono)
else:
marker_corners, marker_ids, _ = cv2.aruco.detectMarkers(img, board.aruco_dict)

if len(marker_corners) == 0:
return (False, None, None)
_, square_corners, ids = cv2.aruco.interpolateCornersCharuco(marker_corners, marker_ids, img, board.charuco_board, minMarkers=1)

return ((square_corners is not None) and (len(square_corners) > 5), square_corners, ids)

def _get_circles(img, board, pattern):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def on_model_change(self, model_select_val):
self.c.set_cammodel( CAMERA_MODEL.PINHOLE if model_select_val < 0.5 else CAMERA_MODEL.FISHEYE)

def on_scale(self, scalevalue):
if self.c.calibrated:
if self.c and self.c.calibrated:
self.c.set_alpha(scalevalue / 100.0)

def button(self, dst, label, enable):
Expand Down
Loading