-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharuco_test
32 lines (24 loc) · 974 Bytes
/
aruco_test
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
32
#https://gist.github.com/hauptmech/6b8ca2c05a3d935c97b1c75ec9ad85ff
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
#choose one of the dictionary 5x5_1000 or 4x4_50 or aruco_original
#dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_5X5_1000)
dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_50)
#dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_ARUCO_ORIGINAL)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
res = cv2.aruco.detectMarkers(gray,dictionary)
# print(res[0],res[1],len(res[2]))
if len(res[0]) > 0:
cv2.aruco.drawDetectedMarkers(gray,res[0],res[1])
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'): #click Q to exit
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()