This commit is contained in:
litian.zhuang 2022-09-29 21:29:05 +08:00
parent 2dacb5064c
commit 11f2a6a56f
1 changed files with 7 additions and 3 deletions

View File

@ -176,6 +176,9 @@ class GraspObject():
# change to opencv # change to opencv
try: try:
cv_image1 = CvBridge().imgmsg_to_cv2(data, "bgr8") cv_image1 = CvBridge().imgmsg_to_cv2(data, "bgr8")
ht = len(cv_image1)
wit= len(cv_image1[0])
cv_image1[0:ht//3,0:wit]=[0,0,0]
except CvBridgeError as e: except CvBridgeError as e:
print('error') print('error')
@ -183,8 +186,8 @@ class GraspObject():
cv_image2 = cv2.cvtColor(cv_image1, cv2.COLOR_BGR2HSV) cv_image2 = cv2.cvtColor(cv_image1, cv2.COLOR_BGR2HSV)
# 蓝色物体颜色检测范围 # 蓝色物体颜色检测范围
LowerBlue = np.array([100, 100, 150]) LowerBlue = np.array([95, 90, 120])
UpperBlue = np.array([140, 255, 255]) UpperBlue = np.array([130, 255, 255])
# LowerBlue = np.array([4, 103, 162]) # LowerBlue = np.array([4, 103, 162])
# UpperBlue = np.array([85, 136, 181]) # UpperBlue = np.array([85, 136, 181])
mask = cv2.inRange(cv_image2, LowerBlue, UpperBlue) mask = cv2.inRange(cv_image2, LowerBlue, UpperBlue)
@ -278,9 +281,10 @@ class GraspObject():
elif height ==3: elif height ==3:
print('nmsl') print('nmsl')
self.pub2.publish(0) self.pub2.publish(0)
r1.sleep() time.sleep(2)
# stop pump # stop pump
self.pub2.publish(0) self.pub2.publish(0)
time.sleep(1)
# r1.sleep() # r1.sleep()
pos.x = 120 pos.x = 120
pos.y = 0 pos.y = 0