-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreencapture.py
51 lines (35 loc) · 1.14 KB
/
screencapture.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import numpy as np
import torch
from matplotlib import pyplot as plt
# git clone https://github.com/ultralytics/yolov5
#
# Load custom model from local files
model = torch.hub.load(r'C:\Users\Pauli\Documents\School\monialaprojekti\yolov5\yolov5', 'custom', path='best', source='local')
img = 'https://ultralytics.com/images/zidane.jpg'
results = model(img)
results.print()
plt.imshow(np.squeeze(results.render()))
plt.show()
results.render()
# simple loop over screenshotted frames
# while True:
# # Take a screenshot
# screen = pyautogui.screenshot()
# # convert to array
# screen_array = np.array(screen)
# # crop region
# crop = screen_array[100:400, 100:1200, :]
# color = cv2.cvtColor(crop, cv2.COLOR_RGB2BGR)
#
# # do detection
# results = model(color)
#
# print(results.xyxy[0]) # im predictions (tensor)
# print(results.pandas().xyxy[0]) # im predictions (pandas)
#
# # show live-detection
# cv2.imshow('SDR-signal', np.squeeze(results.render()))
#
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break
# cv2.destroyAllWindows()