This commit is contained in:
2929ss 2022-07-05 10:33:22 +08:00
parent 2471418b77
commit 3c670989dd
3 changed files with 11 additions and 11 deletions

View file

@ -49,19 +49,19 @@ def take_photo():
def cut_photo():
path_red = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/red'
path_red = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/red'
for i, j, k in os.walk(path_red):
file_len_red = len(k)
path_gray = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/gray'
path_gray = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/gray'
for i, j, k in os.walk(path_gray):
file_len_gray = len(k)
path_green = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/green'
path_green = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/green'
for i, j, k in os.walk(path_green):
file_len_green = len(k)
path_blue = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/blue'
path_blue = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/blue'
for i, j, k in os.walk(path_blue):
file_len_blue = len(k)
print("请截取要识别的部分")
@ -95,19 +95,19 @@ def cut_photo():
cv2.imshow('crop', crop)
# 选择红桶文件夹
if kw == 'red':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/red/goal{}.jpeg'.format(str(file_len_red + 1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/red/goal{}.jpeg'.format(str(file_len_red + 1)),crop)
print('Saved')
# 选择灰桶文件夹
elif kw == 'gray':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/gray/goal{}.jpeg'.format(str(file_len_gray+1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/gray/goal{}.jpeg'.format(str(file_len_gray+1)),crop)
print('Saved')
# 选择绿桶文件夹
elif kw == 'green':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/green/goal{}.jpeg'.format(str(file_len_green+1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/green/goal{}.jpeg'.format(str(file_len_green+1)),crop)
print('Saved')
# 选择蓝桶文件夹
elif kw == 'blue':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/blue/goal{}.jpeg'.format(str(file_len_blue+1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280/res/blue/goal{}.jpeg'.format(str(file_len_blue+1)),crop)
print('Saved')
# 退出

View file

@ -138,7 +138,7 @@ class Object_detect(Movement):
# Grasping motion
def move(self, x, y, color):
# send Angle to move mycobot
print color
print (color)
self.pub_angles(self.move_angles[0], 20)
time.sleep(1.5)
self.pub_angles(self.move_angles[1], 20)

View file

@ -406,7 +406,7 @@ class Object_detect(Movement):
# The path to save the image folder
def parse_folder(folder):
restore = []
path = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/' + folder
path = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myCobot_280' + folder
for i, j, k in os.walk(path):
for l in k:
restore.append(cv2.imread(folder + '/{}'.format(l)))
@ -594,7 +594,7 @@ def run():
detect.sum_y1 += y1
detect.sum_y2 += y2
nparams += 1
print "ok"
print ("ok")
continue
elif nparams == 10:
nparams += 1