生成AprilTag不同家族標(biāo)簽圖像教程
在論文附帶的源碼中,只給出了生成不同的AprilTag家族的JAVA代碼,還有像素值為1的超mini型AprilTag標(biāo)簽圖像,本文主要參考國外一位博主的方案,能夠使官方提供的像素為1的AprilTag標(biāo)簽圖像放大至能使用的程度,并合并至PDF文檔。
生成AprilTag標(biāo)簽的JAVA代碼地址:https://github.com/AprilRobotics/apriltag-generation
預(yù)生成的AprilTag標(biāo)簽圖像地址:https://github.com/AprilRobotics/apriltag-imgs(需要提前clone到本地)
Step 1 獲取預(yù)生成的AprilTag標(biāo)簽圖像
如果在Windows環(huán)境下,請先下載Git,然后在Git Bash中鍵入命令:
git clone https://github.com/AprilRobotics/apriltag-imgs.git
把預(yù)生成的AprilTag標(biāo)簽圖像clone到本地。
如果在Linux環(huán)境下,也在安裝完Git后,直接在Terminal中輸入上述命令即可。
Step 2 安裝ImageMagick
ImageMagick是一個命令行工具,用于在命令行中操作圖像。我們需要利用此工具變換AprilTag標(biāo)簽圖像。
在其官方網(wǎng)頁中下載對應(yīng)操作系統(tǒng)的版本:https://www.imagemagick.org/script/download.php#windows 并完成安裝程序。
Step 3 執(zhí)行resize_tags.sh腳本文件
該文件的下載鏈接為:https://docs.cbteeple.com/assets/files/resize_tags.sh
把該.sh腳本文件,放在剛剛clone下來的apriltag-imgs文件夾的根目錄下。
用記事本打開該文件,可以調(diào)節(jié)相關(guān)參數(shù),在運(yùn)行過程中發(fā)現(xiàn)了一個小bug:腳本執(zhí)行到最后會刪除所有的文件。解決方案有兩種:
- 注釋掉最后的刪除pdf和png文件代碼。
- 把文件開頭的參數(shù):
keep_single_tag_images=false設(shè)置為true,這樣會保留所有的png文件。
可設(shè)置參數(shù):
# ==============================================
# User inputs (change these settings!)
# ==============================================
# Set the folder to use 選擇需要轉(zhuǎn)換的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)