This function will create a totally new dictionary.So it maybe spend a lot of time.(ゼロからDictionaryを作成するため、時間がかなりかかります。)
- zero_custdictionary = cv.aruco.Dictionary_create( markerSize, bitSize )
parameters | purpose | datatype |
---|---|---|
markerSize | The number of markers | Integer |
bitSize | The marker's binary size | Integer |
This function can base on a predefined dictionaries, add a new dictionary. (arUcoの予め準備したDictionaryの上でマーカーの数を追加する。)
- baseDictionary = cv.aruco.getPredefinedDictionr(cv.aruco.DICT_XXX_XXX)
- add_custdictionary = cv.aruco.Dictionary_create_from( markerSize, bitSize, baseDictionary)
- Pay attetion: The new added dictionary's bitSize should be the same as predefined dictionary's.
Source code example
import cv2 as cv
aruco = cv.aruco
dictionary = aruco.getPredefinedDictionary(aruco.DICT_5X5_1000)
#マーカーの数
markerSize = 1050
#マーカーのバイナリーサイズ
bitSize = 5
#カスタマイズDictionary
##arUcoの予め準備したDictionaryの上でマーカーの数を追加する
##例えばここはDICT_5X5_1000を基いて、100個を追加する。マーカーの数が大き程、最初Dictionaryの作成時間がかなりかかります。
custDictionary = aruco.custom_dictionary_from(markerSize, bitSize, dictionary)
##ゼロからDictionaryを作成するため、時間がかなりかかります。
#custDictionary = aruco.custom_dictionary(markerSize,bitSize)
generatMarker(custDictionary, 1040, 1234)
def generatMarker(dic,ID,data):
marker = aruco.drawMarker(dic,ID,data)
cv.imwrite('./ar_'+str(ID)+'_'+str(data)+'.png', marker)
- By the way, I ran the source code above at terminal and editor environment. And the terminal spent less time.
-
For more informatin please check the site:
dictionary.hpp
How to choose a dictionary
- The relationship of correctionBits and markers size.
The inter-marker distance parameter:the minimum distance among its markers and it determines the error detection and correction capabilities of the dictionary.
In general, lower dictionary sizes and higher marker sizes increase the inter-marker and vice-versa. However, the detection of markers with higher sizes is more complex, due to the higher amount of bits that need to be extracted from the image.
(理論的に,marker size(bitSize)が大きい且つmarker数(markerSize)が少ない場合、エラー訂正レベルが高いです。ただし、marker Size(bitSize)が大きすぎると、検知される対象画像の画質の条件も厳しい。)
-
例、200個markerが必要でしたら、同じmarker size(bitSize)6の場合、DICT_6X6_250よりDICT_6X6_1000の方がロバスト性が強い。
-
Create dictionary only one time and can be used at anytime.
The Dictionary parameters are:
class Dictionary{
public:
Mat bytesList; // contains all the information about the marker codes
int markSize;
int maxCorrectionBits;//maximum number of bits that can be corrected
...}
You should save the created dictionary(bytesList) as a csv/yml file. So that you can reuse it by reading this csv/yml file.
- Please reference this site: [save dictionary] (https://github.com/opencv/opencv_contrib/issues/1586)
TODO
- The time of creating a new dictionary.