2021-06-24 生成AprilTag不同家族標(biāo)簽圖像教程

生成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í)行到最后會刪除所有的文件。解決方案有兩種:

  1. 注釋掉最后的刪除pdf和png文件代碼。
  2. 把文件開頭的參數(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)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容