-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlookTranslate.py
65 lines (48 loc) · 2.23 KB
/
lookTranslate.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import cv2
# custom scripts
import screenshoot_process as sp
class Translate:
def __init__(self):
running = True
camera = cv2.VideoCapture(0)
self.width = 0
self.height = 0
self.FPS = 0
if(camera.isOpened()):
sc = sp.screenShootProcess(camera)
camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
while(running):
ret, self.frame = camera.read()
if(ret):
self.drawCameraInfo(self.frame, self.width, self.height, self.FPS)
cv2.imshow("Look Translate", self.frame)
self.width = camera.get(cv2.CAP_PROP_FRAME_WIDTH)
self.height = camera.get(cv2.CAP_PROP_FRAME_HEIGHT)
self.FPS = camera.get(cv2.CAP_PROP_FPS)
if(cv2.waitKey(1) & 0xFF == ord('q')):
running = False
elif(cv2.waitKey(1) & 0xFF == ord('s')):
sc.takeScreenshoot(camera)
else:
print("Cannot read the frame")
running = False
else:
print("Cannot open the camera")
running = False
camera.release()
cv2.destroyAllWindows()
def drawCameraInfo(self, frame, width, height, FPS):
font = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 0.5
color = (255, 255, 255)
thickness = 1
cv2.putText(frame, f"Width: {int(width)}", (10, 30), font, fontScale, color, thickness, cv2.LINE_AA)
cv2.putText(frame, f"Height: {int(height)}", (10, 60), font, fontScale, color, thickness, cv2.LINE_AA)
cv2.putText(frame, f"FPS: {int(FPS)}", (10, 90), font, fontScale, color, thickness, cv2.LINE_AA)
cv2.putText(frame, f'q to exit', (10, 120), font, fontScale, color, thickness, cv2.LINE_AA)
cv2.putText(frame, f's to take screenshot', (10, 150), font, fontScale, color, thickness, cv2.LINE_AA)
cv2.imshow("Look Translate", self.frame)
def translateRequest(self, word):
pass
translate = Translate()