# TensorFlow对象检测CS：Go Aim机器人

import pyautogui

width = 800height = 640monitor = {'top': 80, 'left': 0, 'width': width, 'height': height}

def Shoot(mid_x, mid_y):  x = int(mid_x*width)  y = int(mid_y*height+height/9)  pyautogui.moveTo(x,y)  pyautogui.click()

boxes[0][i][0] â€“ y axis upper start coordinatesboxes[0][i][1] â€“ x axis left start coordinatesboxes[0][i][2] â€“ y axis down start coordinatesboxes[0][i][3] â€“ x axis right start coordinates

array_ch = []for i,b in enumerate(boxes[0]):  if classes[0][i] == 2: # ch    if scores[0][i] >= 0.5:      mid_x = (boxes[0][i][1]+boxes[0][i][3])/2      mid_y = (boxes[0][i][0]+boxes[0][i][2])/2      array_ch.append([mid_x, mid_y])      cv2.circle(image_np,(int(mid_x*width),int(mid_y*height)), 3, (0,0,255), -1)

for i,b in enumerate(boxes[0]):  if classes[0][i] == 2: # ch    if scores[0][i] >= 0.5:      mid_x = (boxes[0][i][1]+boxes[0][i][3])/2      mid_y = (boxes[0][i][0]+boxes[0][i][2])/2      array_ch.append([mid_x, mid_y])      cv2.circle(image_np,(int(mid_x*width),int(mid_y*height)), 3, (0,0,255), -1)  if classes[0][i] == 1: # c     if scores[0][i] >= 0.5:      mid_x = (boxes[0][i][1]+boxes[0][i][3])/2      mid_y = boxes[0][i][0] + (boxes[0][i][2]-boxes[0][i][0])/6      array_c.append([mid_x, mid_y])      cv2.circle(image_np,(int(mid_x*width),int(mid_y*height)), 3, (50,150,255), -1)  if classes[0][i] == 4: # th    if scores[0][i] >= 0.5:      mid_x = (boxes[0][i][1]+boxes[0][i][3])/2      mid_y = (boxes[0][i][0]+boxes[0][i][2])/2      array_th.append([mid_x, mid_y])      cv2.circle(image_np,(int(mid_x*width),int(mid_y*height)), 3, (0,0,255), -1)  if classes[0][i] == 3: # t    if scores[0][i] >= 0.5:      mid_x = (boxes[0][i][1]+boxes[0][i][3])/2      mid_y = boxes[0][i][0] + (boxes[0][i][2]-boxes[0][i][0])/6      array_t.append([mid_x, mid_y])      cv2.circle(image_np,(int(mid_x*width),int(mid_y*height)), 3, (50,150,255), -1)

team = "t"if team == "c":  if len(array_ch) > 0:    Shoot(array_ch[0][0], array_ch[0][1])  if len(array_ch) == 0 and len(array_c) > 0:    Shoot(array_c[0][0], array_c[0][1])if team == "t":  if len(array_th) > 0:    Shoot(array_th[0][0], array_th[0][1])  if len(array_th) == 0 and len(array_t) > 0:    Shoot(array_t[0][0], array_t[0][1])