-
Notifications
You must be signed in to change notification settings - Fork 0
/
arucoWandMaker.py
75 lines (41 loc) · 1.43 KB
/
arucoWandMaker.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import cv2
import libs.rosinterface as IRos
import rospy
import sys
import numpy as np
from sensor_msgs.msg import Image
class LiveThing(object):
def __init__(self):
print("initiated")
self.ids=[]
def callback(self,data):
img = IRos.rosImg2RGB(data)
#What type of aruco markers are there
adict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_ARUCO_ORIGINAL)
#make the image grey
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#get markers
det_corners, ids, rejected = cv2.aruco.detectMarkers(gray,dictionary=adict)
hello = cv2.aruco.drawDetectedMarkers(img,det_corners,ids)
if ids is not None:
for i in ids:
if i not in self.ids:
print(type(i))
print(i.shape)
self.ids.append(i[0])
print(self.ids)
cv2.imshow("Image window" , hello)
cv2.waitKey(1)
if __name__ == "__main__":
arucothing=LiveThing()
camNames = IRos.getAllPluggedCameras()
camName=camNames[0]
rospy.init_node('do_u_kno_di_wae', anonymous=True)
rospy.Subscriber(camName+"/rgb/image_rect_color", Image, arucothing.callback)
print("Fetching Messages")
try:
rospy.spin()
except KeyboardInterrupt:
print("shut")
print("yoyo2")
print(arucothing.ids)