Apriltags v3的Python绑定
pupil-apriltags的Python项目详细描述
小学生apriltags:apriltags3库的Python绑定
这些是由AprilRobotics开发的Apriltags3库的python绑定,经过专门调整后可与学生实验室软件一起使用。最初的绑定是由duckietown提供的,灵感来自Apriltags2 bindings和Matt Zucker。
如何开始:
从pypi安装
这是推荐的最简单的安装瞳孔的方法
$ pip install pupil-apriltags
我们为常见的操作系统提供预构建的二进制轮子。 如果系统不匹配,则安装可能需要一些时间,因为将首先编译本机库(apriltags源)
通过github的当前主分支从源安装
$ pip install git+https://github.com/pupil-labs/apriltags
从源头手动安装
当然,您可以手动克隆存储库并从中构建。我们使用scikit-build而不是普通的python设置工具,因为skbuild使使用本机库更加容易。构建仍然通过标准的python setup.py [options]
命令进行控制,但是skbuild负责在后台独立编译aprltags源代码。
用法
在src/pupil_apriltags/bindings.py
文件中可以看到一些用法示例。
Detector
类是apriltags功能的包装器。您可以如下初始化:
at_detector = Detector(searchpath=['apriltags'],
families='tag36h11',
nthreads=1,
quad_decimate=1.0,
quad_sigma=0.0,
refine_edges=1,
decode_sharpening=0.25,
debug=0)
选项是:
Option | Default | Explanation |
---|---|---|
families | 'tag36h11' | Tag families, separated with a space |
nthreads | 1 | Number of threads |
quad_decimate | 2.0 | Detection of quads can be done on a lower-resolution image, improving speed at a cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still done at full resolution. Set this to 1.0 to use the full resolution. |
quad_sigma | 0.0 | What Gaussian blur should be applied to the segmented image. Parameter is the standard deviation in pixels. Very noisy images benefit from non-zero values (e.g. 0.8) |
refine_edges | 1 | When non-zero, the edges of the each quad are adjusted to "snap to" strong gradients nearby. This is useful when decimation is employed, as it can increase the quality of the initial quad estimate substantially. Generally recommended to be on (1). Very computationally inexpensive. Option is ignored if quad_decimate = 1 |
decode_sharpening | 0.25 | How much sharpening should be done to decoded images? This can help decode small tags but may or may not help in odd lighting conditions or low light conditions |
searchpath | ['apriltags'] | Where to look for the Apriltag 3 library, must be a list |
debug | 0 | If 1, will save debug images. Runs very slow |
通过运行检测器的detect
方法来检测图像中的标记:
tags = at_detector.detect(img, estimate_tag_pose=False, camera_params=None, tag_size=None)
如果还要提取标记姿势,则应将estimate_tag_pose
设置为True
,并应提供camera_params
([fx, fy, cx, cy]
)和tag_size
(以米为单位)detect
方法返回一个Detection
对象列表,每个对象都具有以下属性(请注意,带星号的对象仅在estimate_tag_pose=True
时计算):
Attribute | Explanation |
---|---|
tag_family | The family of the tag. |
tag_id | The decoded ID of the tag. |
hamming | How many error bits were corrected? Note: accepting large numbers of corrected errors leads to greatly increased false positive rates. NOTE: As of this implementation, the detector cannot detect tags with a Hamming distance greater than 2. |
decision_margin | A measure of the quality of the binary decoding process: the average difference between the intensity of a data bit versus the decision threshold. Higher numbers roughly indicate better decodes. This is a reasonable measure of detection accuracy only for very small tags-- not effective for larger tags (where we could have sampled anywhere within a bit cell and still gotten a good detection.) |
homography | The 3x3 homography matrix describing the projection from an "ideal" tag (with corners at (-1,1), (1,1), (1,-1), and (-1, -1)) to pixels in the image. |
center | The center of the detection in image pixel coordinates. |
corners | The corners of the tag in image pixel coordinates. These always wrap counter-clock wise around the tag. |
pose_R* | Rotation matrix of the pose estimate. |
pose_t* | Translation of the pose estimate. |
pose_err* | Object-space error of the estimation. |
自定义布局
如果要使用自定义布局,则需要为其创建C源文件和头文件,然后重新生成库。然后使用新的libapriltag.so
库您可以找到有关原始Apriltags repository的更多信息