This commit is contained in:
monoKim 2020-11-03 14:59:10 +01:00
parent d0c32c4d9a
commit 447a830e84

View file

@ -13,13 +13,14 @@ size_scale = 3
while True:
# Get rect of Window
hwnd = win32gui.FindWindow(None, 'Counter-Strike: Global Offensive')
#hwnd = win32gui.FindWindow("UnrealWindow", None) # Fortnite
rect = win32gui.GetWindowRect(hwnd)
region = rect[0], rect[1], rect[2] - rect[0], rect[3] - rect[1]
# Get image of screen
image = np.array(pyautogui.screenshot(region=region))
image = cv2.resize(image, (image.shape[1] // size_scale, image.shape[0] // size_scale))
image = np.expand_dims(image, 0)
ori_img = np.array(pyautogui.screenshot(region=region))
ori_img = cv2.resize(ori_img, (ori_img.shape[1] // size_scale, ori_img.shape[0] // size_scale))
image = np.expand_dims(ori_img, 0)
img_w, img_h = image.shape[2], image.shape[1]
# Detection
@ -35,10 +36,12 @@ while True:
# Choose only person(class:1)
if classes[i] == 1 and scores[i] >= 0.5:
ymin, xmin, ymax, xmax = tuple(box)
if ymin > 0.5 and ymax > 0.8:
if ymin > 0.5 and ymax > 0.8: # CS:Go
#if int(xmin * img_w * 3) < 450: # Fortnite
continue
left, right, top, bottom = int(xmin * img_w), int(xmax * img_w), int(ymin * img_h), int(ymax * img_h)
detected_boxes.append((left, right, top, bottom))
#cv2.rectangle(ori_img, (left, top), (right, bottom), (255, 255, 0), 2)
print("Detected:", len(detected_boxes))
@ -71,4 +74,8 @@ while True:
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
#ori_img = cv2.cvtColor(ori_img, cv2.COLOR_BGR2RGB)
#cv2.imshow("ori_img", ori_img)
#cv2.waitKey(1)
time.sleep(0.1)