refactored
This commit is contained in:
@@ -3,11 +3,11 @@ import math
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
from utils import to_board_pose_euler
|
||||
from .utils import to_board_pose_euler
|
||||
|
||||
RESULTS_FOLDER = "results"
|
||||
|
||||
class ArTagPose(abc.ABC):
|
||||
class BoardPose(abc.ABC):
|
||||
detector: cv.aruco.ArucoDetector | cv.aruco.CharucoDetector = None
|
||||
board: cv.aruco.GridBoard | cv.aruco.CharucoBoard = None
|
||||
mtx = None
|
||||
@@ -77,7 +77,7 @@ class ArTagPose(abc.ABC):
|
||||
|
||||
# Open camera
|
||||
cap = cv.VideoCapture(0)
|
||||
ArTagPose.cap_init(cap)
|
||||
BoardPose.cap_init(cap)
|
||||
|
||||
if not cap.isOpened():
|
||||
print("Cannot open camera")
|
||||
@@ -1,7 +1,7 @@
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from ar_tag_pose import ArTagPose
|
||||
from aruco_types import ARUCO_DICT
|
||||
from .board_pose import BoardPose
|
||||
from .types import ARUCO_DICT
|
||||
|
||||
def factory(dict_type: int, board_size: cv.typing.Size, marker_length: float=100.0, marker_sep=10):
|
||||
aruco_dict = cv.aruco.getPredefinedDictionary(dict_type)
|
||||
@@ -13,9 +13,9 @@ def factory(dict_type: int, board_size: cv.typing.Size, marker_length: float=100
|
||||
|
||||
return detector, board, name
|
||||
|
||||
class ArTagPoseArucoBoard(ArTagPose):
|
||||
class BoardPoseAruco(BoardPose):
|
||||
def __init__(self, dict_type: int, board_size: tuple[int, int]):
|
||||
ArTagPose.__init__(self)
|
||||
BoardPose.__init__(self)
|
||||
self.board_size = board_size
|
||||
self.detector, self.board, self.name = factory(dict_type, board_size)
|
||||
|
||||
@@ -84,7 +84,7 @@ class ArTagPoseArucoBoard(ArTagPose):
|
||||
return pose, r_vec, t_vec
|
||||
|
||||
def main():
|
||||
pose = ArTagPoseArucoBoard(10, (5,5))
|
||||
pose = BoardPoseAruco(10, (5, 5))
|
||||
pose.board_image_generate(margin_length=10)
|
||||
pose.calibrate_load()
|
||||
pose.process()
|
||||
@@ -1,7 +1,7 @@
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from ar_tag_pose import ArTagPose
|
||||
from aruco_types import ARUCO_DICT
|
||||
from .board_pose import BoardPose
|
||||
from .types import ARUCO_DICT
|
||||
|
||||
def factory(dict_type: int, board_size: cv.typing.Size, square_length: float = 5.0, marker_length: float = 3.0):
|
||||
aruco_dict = cv.aruco.getPredefinedDictionary(dict_type)
|
||||
@@ -13,9 +13,9 @@ def factory(dict_type: int, board_size: cv.typing.Size, square_length: float = 5
|
||||
|
||||
return detector, board, name
|
||||
|
||||
class ArTagPoseCharucoBoard(ArTagPose):
|
||||
class BoardPoseCharuco(BoardPose):
|
||||
def __init__(self, dict_type: int, board_size: tuple[int, int]):
|
||||
ArTagPose.__init__(self)
|
||||
BoardPose.__init__(self)
|
||||
self.board_size = board_size
|
||||
self.detector, self.board, self.name = factory(dict_type, board_size)
|
||||
|
||||
@@ -82,7 +82,7 @@ class ArTagPoseCharucoBoard(ArTagPose):
|
||||
return pose, r_vec, t_vec
|
||||
|
||||
def main():
|
||||
pose = ArTagPoseCharucoBoard(10, (6,7))
|
||||
pose = BoardPoseCharuco(10, (6, 7))
|
||||
pose.board_image_generate()
|
||||
pose.calibrate_load()
|
||||
pose.process()
|
||||
Reference in New Issue
Block a user