Skip to content

Instantly share code, notes, and snippets.

@tac-yacht
Last active November 14, 2021 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tac-yacht/228da1a34ad51a9fd0da772237f9c91a to your computer and use it in GitHub Desktop.
Save tac-yacht/228da1a34ad51a9fd0da772237f9c91a to your computer and use it in GitHub Desktop.
Vieurekaサンプルアプリ「ARマーカー認識アプリ」のARタグ生成
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ref by https://qiita.com/suo-takefumi/items/30a225cef8ea42366f8e
# usage
# gen_dict_6x6_250.py
# result file -> ar_0.png
#
# gen_dict_6x6_250.py 1
# result file -> ar_1.png
#
# gen_dict_6x6_250.py 0 5
# result file -> ar_0.png, ar_1.png, ar_2.png, ar_3.png, ar_4.png, ar_5.png
import sys
start = int(sys.argv[1]) if len(sys.argv)>1 else 0
end = (int(sys.argv[2]) if len(sys.argv)>2 else start)+1
import cv2
aruco = cv2.aruco
dictionary = aruco.getPredefinedDictionary(aruco.DICT_6X6_250)
def arGenerator(id):
fileName = "ar_{}.png".format(id)
# 第二引数:ID番号,第三引数:150x150ピクセル
generator = aruco.drawMarker(dictionary, id, 150)
cv2.imwrite(fileName, generator)
for i in range(start,end):
arGenerator(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment