x
This commit is contained in:
31
test.py
31
test.py
@ -43,24 +43,37 @@ def create_charuco_board(
|
|||||||
IMAGE_PATH= Path("/Users/crosstyan/Downloads/IMG_1505.jpeg")
|
IMAGE_PATH= Path("/Users/crosstyan/Downloads/IMG_1505.jpeg")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
...
|
|
||||||
img: MatLike
|
img: MatLike
|
||||||
img = cv2.imread(str(IMAGE_PATH))
|
img = cv2.imread(str(IMAGE_PATH))
|
||||||
# 10x7
|
# 10x7
|
||||||
|
border_num_x = 10
|
||||||
|
border_num_y = 7
|
||||||
# 115mm square
|
# 115mm square
|
||||||
# 90mm marker
|
# 90mm marker
|
||||||
dictionary = ArucoDictionary.Dict_4X4_50
|
dictionary = ArucoDictionary.Dict_4X4_50
|
||||||
predifined = aruco.getPredefinedDictionary(dictionary.value)
|
predifined = aruco.getPredefinedDictionary(dictionary.value)
|
||||||
# https://docs.opencv.org/4.x/d9/d6a/group__aruco.html#ga3bc50d61fe4db7bce8d26d56b5a6428a
|
# https://docs.opencv.org/4.x/d9/d6a/group__aruco.html#ga3bc50d61fe4db7bce8d26d56b5a6428a
|
||||||
# https://docs.opencv.org/4.x/df/d4a/tutorial_charuco_detection.html
|
# https://docs.opencv.org/4.x/df/d4a/tutorial_charuco_detection.html
|
||||||
corners, ids, rejected = aruco.detectMarkers(img, predifined)
|
# https://docs.opencv.org/3.4/df/d4a/tutorial_charuco_detection.html
|
||||||
board = create_charuco_board(10, 7, 115, 90, predifined)
|
# https://docs.opencv.org/4.x/dc/dbb/tutorial_py_calibration.html
|
||||||
if ids is not None:
|
|
||||||
aruco.drawDetectedMarkers(img, corners, ids)
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
_, ch_corners, ch_ids = aruco.interpolateCornersCharuco(corners, ids, img, board)
|
ret, chess_corners = cv2.findChessboardCorners(gray, (border_num_x, border_num_y), None)
|
||||||
if ch_corners is not None and ch_ids is not None:
|
if ret:
|
||||||
aruco.drawDetectedCornersCharuco(img, ch_corners, ch_ids)
|
cv2.drawChessboardCorners(img, (border_num_x, border_num_y), chess_corners, ret)
|
||||||
cv2.imwrite("output.jpg", img)
|
cv2.imwrite("output.jpg", img)
|
||||||
|
else:
|
||||||
|
print("not found")
|
||||||
|
|
||||||
|
# corners, ids, rejected = aruco.detectMarkers(img, predifined)
|
||||||
|
# board = create_charuco_board(10, 7, 115, 90, predifined)
|
||||||
|
# detector = aruco.CharucoDetector(board)
|
||||||
|
# if ids is not None:
|
||||||
|
# aruco.drawDetectedMarkers(img, corners, ids)
|
||||||
|
# _, ch_corners, ch_ids = aruco.interpolateCornersCharuco(corners, ids, img, board)
|
||||||
|
# if ch_corners is not None and ch_ids is not None:
|
||||||
|
# aruco.drawDetectedCornersCharuco(img, ch_corners, ch_ids)
|
||||||
|
# cv2.imwrite("output.jpg", img)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user