AprilTag 角点检测
该部分主要由 ApriltagCornerDetector 类提供,该类用于检测图像中的 AprilTag 标签。
主要功能:
自动检测图像中的 AprilTag 标签。
支持输入图像路径或 numpy 数组作为输入。
提供直接检测和绘制检测结果的方法。
主要方法:
__init__(self): 初始化检测器,并检测或安装所需的第三方库。
detect(self, image: Union[str, Path, np.ndarray], show_result: bool = False): 接收图像(路径或数组),返回检测结果。如果 show_result 为 True,则显示检测结果。
detect_and_draw(self, image: Union[str, np.ndarray]) -> np.ndarray: 在原图上绘制检测结果,并返回绘制后的图像。
示例:
>>> from pywayne.cv.apriltag_detector import ApriltagCornerDetector
>>> detector = ApriltagCornerDetector()
>>> detections = detector.detect('test.png', show_result=True)
- class pywayne.cv.apriltag_detector.ApriltagCornerDetector(tag_family: str = '36h11', black_border: int = 2, preprocess: str | Sequence[str] | None = None, clahe_clip_limit: float = 2.0, clahe_tile_grid_size=(8, 8))
Bases:
object- detect(image: str | Path | ndarray, show_result: bool = False, preprocess=None)
检测图像中的AprilTag
- Parameters:
image – 输入图像,可以是图片路径(str/Path)或者numpy数组(np.ndarray)
show_result – 是否显示结果
preprocess – 可选预处理,支持 None、”norm”、”clahe”、”equalize”、 “norm-clahe”,或这些模式组成的列表。
- Returns:
检测结果
- Return type:
detections
- detect_and_draw(image: str | Path | ndarray, preprocess=None) ndarray
检测图像中的AprilTag并在原图上绘制结果
- Parameters:
image – 输入图像,可以是图片路径(str)或者numpy数组(np.ndarray)
preprocess – 传给 detect() 的可选预处理模式
- Returns:
绘制了检测结果的图像(与输入图像大小相同)
- Return type:
np.ndarray