-
Notifications
You must be signed in to change notification settings - Fork 0
/
low_light.py
67 lines (54 loc) · 2.11 KB
/
low_light.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
66
67
def PTS():
import cv2
import numpy as np
import pytesseract
import ocr2
import ttos
cap = cv2.VideoCapture('http://192.168.43.1:8080/video')
cv2.namedWindow('image',cv2.WINDOW_NORMAL)
while(True):
while(True):
ret, img = cap.read()
cv2.imshow('image',img)
if ((cv2.waitKey(1) & 0xFF) == ord('q')):
break
# Apply dilation and erosion to remove some noise
#kernel = np.ones((1, 1), np.uint8)
#img = cv2.dilate(img, kernel, iterations=1)
#img = cv2.erode(img, kernel, iterations=1)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#kernel = np.ones((5,5),np.float32)/25
#dst = cv2.filter2D(img,-1,kernel)
#retval, threshold = cv2.threshold(gray, 12, 255, cv2.THRESH_BINARY)
#th = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 115, 1)
#dst = cv2.fastNlMeansDenoisingColored(th,None,10,10,7,21)
cv2.imshow('image1',gray)
#cv2.imshow('frame2',gray)
#print("gray:")
#th = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 115, 1)
#blur = cv2.GaussianBlur(th,(15,15),0)
text=(ocr2.ocr(gray))
print(text)
#cv2.imshow('image2',g)
ttos.text_to_speech("I am speaking what is written in the image"+text)
# Create a black image
#img = np.zeros((512,512,3), np.uint8)
# Write some Text
#font = cv2.FONT_HERSHEY_SIMPLEX
#bottomLeftCornerOfText = (10,10)
## fontColor = (255,255,255)
# lineType = 2
# cv2.putText(img,text,
# bottomLeftCornerOfText,
# font,
# fontScale,
# fontColor,
# lineType)
#Display the image
# cv2.imshow("img",img)
# print("normal:")
# ocr2.ocr(th)
if ((cv2.waitKey(1) & 0xFF) == ord('e')):
break
cap.release()
cv2.destroyAllWindows()