-
Notifications
You must be signed in to change notification settings - Fork 0
/
gif.py
29 lines (22 loc) · 816 Bytes
/
gif.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
import cv2
import numpy as np
import pyautogui
import time
class GIF:
__slots__ = ('folder', 'region')
def __init__(self, folder: str, region: tuple[int, int, int, int] = (460, 60, 975, 975)):
self.folder = folder
self.region = region
def test(self):
cv2.imshow('chess', cv2.cvtColor(np.array(pyautogui.screenshot(region=self.region)), cv2.COLOR_RGB2BGR))
cv2.waitKey(0)
def get(self, n: int = 60, delay: float = 2):
time.sleep(delay)
print('starting capture')
for i in range(n):
s = cv2.cvtColor(np.array(pyautogui.screenshot(region=self.region)), cv2.COLOR_RGB2BGR)
cv2.imwrite(f'{self.folder}\\frm{n - i - 1}.png', s)
print('end capture')
if __name__ == '__main__':
gif = GIF(FOLDER)
gif.get()