-
Notifications
You must be signed in to change notification settings - Fork 1
/
image.py
21 lines (21 loc) · 901 Bytes
/
image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PIL import Image
import mss
import numpy as np
def getCellsTrader():
# each cell is a 64x64 pixel RGB image
top = 261
left = 8
size = 64
cell = []
coord = []
with mss.mss() as sct:
for i in range(0,11):
for j in range(0,10):
sct_img = sct.grab({"top": top, "left": left, "width": size, "height": size}) # grab desired area of monitor (each cell)
pilImage = np.array(Image.frombytes("RGB", sct_img.size, sct_img.bgra, "raw", "BGRX")) # turn that image into a numpy array in the format RGB, instead of mss default BGRA
cell.append(pilImage[None, :]) # reshape the pilImage numpy array to have a "None" value at the start, this is what the model requires
coord.append((left+32, top+32))
left+=63
left = 8
top+=63
return cell, coord