use ndarray instead of MatLike

This commit is contained in:
2025-12-02 21:35:07 +01:00
parent 5d2fd557d1
commit 1d7c3e25bc
3 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -44,17 +44,17 @@ class BoardDetector(abc.ABC):
pass
@abc.abstractmethod
def match_points(self, image: cv.typing.MatLike):
def match_points(self, image: np.ndarray):
pass
@abc.abstractmethod
def process(self, image: cv.typing.MatLike, draw_marker_box=True, draw_marker_id=False, draw_marker_axis=True) -> (bool, np.ndarray, np.ndarray):
def process(self, image: np.ndarray, draw_marker_box=True, draw_marker_id=False, draw_marker_axis=True) -> (bool, np.ndarray, np.ndarray):
pass
def is_calibrated(self):
return self.mtx is not None and self.dist is not None
def collect_points(self, image: cv.typing.MatLike) -> bool:
def collect_points(self, image: np.ndarray) -> bool:
success, obj_points, img_points = self.match_points(image)
if success:
self.obj_points_list.append(obj_points)
@@ -79,7 +79,7 @@ class BoardDetector(abc.ABC):
def calibration_get(self):
return self.mtx, self.dist, self.r_vecs, self.t_vecs
def calibrate_camera(self, image: cv.typing.MatLike, r_vecs=None, t_vecs=None, flags=0):
def calibrate_camera(self, image: np.ndarray, r_vecs=None, t_vecs=None, flags=0):
success = False
if len(self.obj_points_list) > 0 and len(self.img_points_list) > 0:
ret, mtx, dist, r_vecs, t_vecs = cv.calibrateCamera(self.obj_points_list, self.img_points_list, image.shape, self.mtx, self.dist,
+2 -2
View File
@@ -31,7 +31,7 @@ class BoardDetectorAruco(BoardDetector):
image = self.board.generateImage(image_size, None, margin_length, 1)
return image
def match_points(self, image: cv.typing.MatLike):
def match_points(self, image: np.ndarray):
success = False
obj_points = None
img_points = None
@@ -48,7 +48,7 @@ class BoardDetectorAruco(BoardDetector):
return success, obj_points, img_points
def process(self, image: cv.typing.MatLike, r_vecs: np.ndarray=None, t_vecs: np.ndarray=None, draw_marker_box=True, draw_marker_id=False, draw_marker_axis=False):
def process(self, image: np.ndarray, r_vecs: np.ndarray=None, t_vecs: np.ndarray=None, draw_marker_box=True, draw_marker_id=False, draw_marker_axis=False):
pose = False
r_vec = None
t_vec = None
+2 -2
View File
@@ -32,7 +32,7 @@ class BoardDetectorCharuco(BoardDetector):
image = self.board.generateImage(image_size, None, margin_length, 1)
return image
def match_points(self, image: cv.typing.MatLike):
def match_points(self, image: np.ndarray):
success = False
obj_points = None
img_points = None
@@ -49,7 +49,7 @@ class BoardDetectorCharuco(BoardDetector):
return success, obj_points, img_points
def process(self, image: cv.typing.MatLike, r_vecs: np.ndarray=None, t_vecs: np.ndarray=None, draw_marker_box=True, draw_marker_id=False, draw_marker_axis=False):
def process(self, image: np.ndarray, r_vecs: np.ndarray=None, t_vecs: np.ndarray=None, draw_marker_box=True, draw_marker_id=False, draw_marker_axis=False):
pose = False
r_vec = None
t_vec = None