2021-06-24 生成AprilTag不同家族标签图像教程

生成AprilTag不同家族标签图像教程

在论文附带的源码中,只给出了生成不同的AprilTag家族的JAVA代码,还有像素值为1的超mini型AprilTag标签图像,本文主要参考国外一位博主的方案,能够使官方提供的像素为1的AprilTag标签图像放大至能使用的程度,并合并至PDF文档。

生成AprilTag标签的JAVA代码地址:https://github.com/AprilRobotics/apriltag-generation

预生成的AprilTag标签图像地址:https://github.com/AprilRobotics/apriltag-imgs(需要提前clone到本地)

Step 1 获取预生成的AprilTag标签图像

如果在Windows环境下,请先下载Git,然后在Git Bash中键入命令:

git clone https://github.com/AprilRobotics/apriltag-imgs.git

把预生成的AprilTag标签图像clone到本地。

如果在Linux环境下,也在安装完Git后,直接在Terminal中输入上述命令即可。

Step 2 安装ImageMagick

ImageMagick是一个命令行工具,用于在命令行中操作图像。我们需要利用此工具变换AprilTag标签图像。

在其官方网页中下载对应操作系统的版本:https://www.imagemagick.org/script/download.php#windows 并完成安装程序。

Step 3 执行resize_tags.sh脚本文件

该文件的下载链接为:https://docs.cbteeple.com/assets/files/resize_tags.sh

把该.sh脚本文件,放在刚刚clone下来的apriltag-imgs文件夹的根目录下。

用记事本打开该文件,可以调节相关参数,在运行过程中发现了一个小bug:脚本执行到最后会删除所有的文件。解决方案有两种:

  1. 注释掉最后的删除pdf和png文件代码。
  2. 把文件开头的参数:keep_single_tag_images=false设置为true,这样会保留所有的png文件。

可设置参数:

# ==============================================
# User inputs (change these settings!)
# ==============================================

# Set the folder to use 选择需要转换的AprilTag家族
FILES=tag36h11/*.png  # Set the folder to convert from

# Set the desired width of your tags
width=30.0         # [mm]  Set the desired width in real units
dpi=300            # [ppi] Set the dpi (to control the print quality)
extra_margin=1     # [px]  Add an extra margin around your tags
default_width=10.0 # [px]  The pixel width of the original images

# Set the grid size you want to make
grid_h=4           # [num] Number of rows
grid_w=6           # [num] Number of columns
grid_filetype=pdf  # [png, jpg, pdf] Set the filetype for the grids

# Decide whether to keep intermediate files 选择是否保留临时文件
keep_single_tag_images=false

可注释的删除pdf代码

# Combine all single-page PDFs into one
if [ "$grid_filetype" == "pdf" ]; then
    echo "Combining PDFs"
    sleep 1
    convert -density ${dpi} ${OUTFOLDER}/*.pdf ${OUTFOLDER}/all_tags.pdf
    #注释下一行
    #rm -r $OUTFOLDER/grid*  
fi

if [ "$keep_single_tag_images" != true ]; then
    #注释下一行
    #rm -r $OUTFOLDER/*.png
fi

Overall

tag36h11 全系列图片的下载地址: https://cloud.189.cn/web/share?code=JbyyYn2Afeym(访问码:r90u)

你可能感兴趣的:(2021-06-24 生成AprilTag不同家族标签图像教程)