-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_tag.py
executable file
·31 lines (23 loc) · 983 Bytes
/
generate_tag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
File to generate and save aruco markers
@author: Robin Amsters
@email: [email protected]
Original file: http://www.philipzucker.com/aruco-in-opencv/
Generates an aruco marker with a size of the specified number of pixels. Paste this image for example in word to fix the physical dimensions in meters (needed for detection later).
"""
import cv2
import cv2.aruco as aruco
# Paramters for marker generation
n_markers = 1 # Number of tags to generate
imageSize = 700 # Size of image in pixels
for i in range(n_markers):
markerID = i
# Get dictionary
aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_50)
# Generate and save marker
img = aruco.drawMarker(aruco_dict, markerID, imageSize) # dictionary, id, image size
cv2.imwrite("marker_" + str(markerID) + "_pxl_" + str(imageSize) +".png", img) # Save image
# Show marker untill key is pressed
cv2.imshow('Generated marker',img)
cv2.waitKey(0)
cv2.destroyAllWindows()