Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JojiJoseph committed Nov 22, 2021
0 parents commit 3f900c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Aruco Detector
Convert OpenCV aruco dictionaries to custom dictionaries
```bash
python3 convert_dicts.py
```
28 changes: 28 additions & 0 deletions convert_dicts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import cv2.aruco as aruco
import cv2
import os
import numpy as np
import pickle
from tqdm import tqdm

predefined_dicts = {name:getattr(aruco,name) for name in dir(aruco) if name.startswith("DICT_")}

os.makedirs("./dict", exist_ok=True)

for key in tqdm(predefined_dicts.keys()):
dict_val = predefined_dicts[key]
dict = aruco.getPredefinedDictionary(dict_val)
n_markers = len(dict.bytesList)
new_dict = {}
for i in range(n_markers):
img = dict.drawMarker(i, (dict.markerSize+2))
img //= 255
new_dict[tuple(img.ravel())] = (i,0)
img = np.rot90(img)
new_dict[tuple(img.ravel())] = (i,1)
img = np.rot90(img)
new_dict[tuple(img.ravel())] = (i,2)
img = np.rot90(img)
new_dict[tuple(img.ravel())] = (i,3)
with open(os.path.join("./dict",key + ".pickle"), "wb") as f:
pickle.dump(new_dict, f)

0 comments on commit 3f900c8

Please sign in to comment.