use ndarray instead of MatLike
This commit is contained in:
@@ -44,17 +44,17 @@ class BoardDetector(abc.ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def match_points(self, image: cv.typing.MatLike):
|
def match_points(self, image: np.ndarray):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@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
|
pass
|
||||||
|
|
||||||
def is_calibrated(self):
|
def is_calibrated(self):
|
||||||
return self.mtx is not None and self.dist is not None
|
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)
|
success, obj_points, img_points = self.match_points(image)
|
||||||
if success:
|
if success:
|
||||||
self.obj_points_list.append(obj_points)
|
self.obj_points_list.append(obj_points)
|
||||||
@@ -79,7 +79,7 @@ class BoardDetector(abc.ABC):
|
|||||||
def calibration_get(self):
|
def calibration_get(self):
|
||||||
return self.mtx, self.dist, self.r_vecs, self.t_vecs
|
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
|
success = False
|
||||||
if len(self.obj_points_list) > 0 and len(self.img_points_list) > 0:
|
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,
|
ret, mtx, dist, r_vecs, t_vecs = cv.calibrateCamera(self.obj_points_list, self.img_points_list, image.shape, self.mtx, self.dist,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class BoardDetectorAruco(BoardDetector):
|
|||||||
image = self.board.generateImage(image_size, None, margin_length, 1)
|
image = self.board.generateImage(image_size, None, margin_length, 1)
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def match_points(self, image: cv.typing.MatLike):
|
def match_points(self, image: np.ndarray):
|
||||||
success = False
|
success = False
|
||||||
obj_points = None
|
obj_points = None
|
||||||
img_points = None
|
img_points = None
|
||||||
@@ -48,7 +48,7 @@ class BoardDetectorAruco(BoardDetector):
|
|||||||
|
|
||||||
return success, obj_points, img_points
|
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
|
pose = False
|
||||||
r_vec = None
|
r_vec = None
|
||||||
t_vec = None
|
t_vec = None
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class BoardDetectorCharuco(BoardDetector):
|
|||||||
image = self.board.generateImage(image_size, None, margin_length, 1)
|
image = self.board.generateImage(image_size, None, margin_length, 1)
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def match_points(self, image: cv.typing.MatLike):
|
def match_points(self, image: np.ndarray):
|
||||||
success = False
|
success = False
|
||||||
obj_points = None
|
obj_points = None
|
||||||
img_points = None
|
img_points = None
|
||||||
@@ -49,7 +49,7 @@ class BoardDetectorCharuco(BoardDetector):
|
|||||||
|
|
||||||
return success, obj_points, img_points
|
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
|
pose = False
|
||||||
r_vec = None
|
r_vec = None
|
||||||
t_vec = None
|
t_vec = None
|
||||||
|
|||||||
Reference in New Issue
Block a user