update aikit_shape.py

This commit is contained in:
weijian 2022-12-09 15:49:03 +08:00
parent 69912d2ceb
commit 768835570a

View file

@ -68,16 +68,7 @@ class Object_detect():
self.x1 = self.x2 = self.y1 = self.y2 = 0
# set cache of real coord
self.cache_x = self.cache_y = 0
# set color HSV
self.HSV = {
# "yellow": [np.array([11, 85, 70]), np.array([59, 255, 245])],
"yellow": [np.array([22, 93, 0]), np.array([45, 255, 245])],
"red": [np.array([0, 43, 46]), np.array([8, 255, 255])],
"green": [np.array([35, 43, 35]), np.array([90, 255, 255])],
"blue": [np.array([100, 43, 46]), np.array([124, 255, 255])],
"cyan": [np.array([78, 43, 46]), np.array([99, 255, 255])],
}
# use to calculate coord between cube and mycobot
self.sum_x1 = self.sum_x2 = self.sum_y2 = self.sum_y1 = 0
# The coordinates of the grab center point relative to the mycobot
@ -125,7 +116,7 @@ class Object_detect():
time.sleep(3)
# send coordinates to move mycobot
self.mc.send_coords([x, y, 190.6, 179.87, -3.78, -62.75], 25, 1) # usb :rx,ry,rz -173.3, -5.48, -57.9
self.mc.send_coords([x, y, 170.6, 179.87, -3.78, -62.75], 25, 1) # usb :rx,ry,rz -173.3, -5.48, -57.9
time.sleep(3)
# self.mc.send_coords([x, y, 150, 179.87, -3.78, -62.75], 25, 0)
@ -151,7 +142,7 @@ class Object_detect():
# print(tmp)
self.mc.send_angles([tmp[0], -0.71, -54.49, -23.02, -0.79, tmp[5]],25) # [18.8, -7.91, -54.49, -23.02, -0.79, -14.76]
time.sleep(2.5)
time.sleep(3)
self.mc.send_coords(self.move_coords[color], 25, 1)
@ -269,7 +260,7 @@ class Object_detect():
if self.x1 != self.x2:
# the cutting ratio here is adjusted according to the actual situation
frame = frame[int(self.y2*0.78):int(self.y1*1.1),
int(self.x1*0.88):int(self.x2*1.06)]
int(self.x1*0.86):int(self.x2*1.08)]
return frame
# 检测物体的形状