-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZoomC.py
50 lines (33 loc) · 1.47 KB
/
ZoomC.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
import cv2
class Zoom:
def __init__(self, mouse):
self.startDist = None
self.scale = 0
self.cx, self.cy = 500,500
self.mouse = mouse
def activate(self,kek):
#if kek == None:
#return img
kek["grImg"] = cv2.imread(f'ImageGraphics\{kek["name"]}.jpg')
kek["grImg"] = cv2.resize(kek["grImg"],(400,400), False, 0, 0)
if len(self.mouse.hands) == 2:
# print(detector.fingersUp(hands[ 0]), detector.fingersUp(hands[ 1]))
if self.mouse.fingerUp1 == [ 1, 1, 0, 0, 0] and self.mouse.fingerUp2 == [ 1, 1, 0, 0, 0]:
if self.startDist is None:
self.startDist = self.mouse.lenCenterHand
self.scale = int((self.mouse.lenCenterHand - self.startDist) // 2)
self.cx, self.cy = self.mouse.infoHand[ 4:]
else:
self.startDist = None
try:
h1, w1, _= kek["grImg"].shape
newH, newW = ((h1+self.scale)//2)*2, ((w1+self.scale)//2)*2
kek["grImg"] = cv2.resize(kek["grImg"], (newW,newH))
#img[ self.cy-newH//2 : self.cy+ newH//2, self.cx-newW//2:self.cx+ newW//2] = kek["grImg"]
kek["cy"] = self.cy-newH//2
kek["cy1"] = self.cy+ newH//2
kek["cx"] = self.cx-newW//2
kek["cx1"] = self.cx+ newW//2
except:
pass
return kek