-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3f900c8
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |