-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcamera_settings.py
53 lines (43 loc) · 1.47 KB
/
camera_settings.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
import os
import cv2
# attrib_list = {
# "exposure": cv2.CAP_PROP_EXPOSURE,
# "contrast": cv2.CAP_PROP_CONTRAST
# }
def check_settings():
VIDEO_CHECK = cv2.VideoCapture(0)
if not os.path.exists("camera_settings.log"):
f = open("camera_settings.log", "w")
for attrib, index in attrib_list.items():
f.writelines(f"{attrib} = {VIDEO_CHECK.get(index)}\n")
f.close()
else:
f = open("camera_settings.log", "r")
lines = f.read().split("\n")
for line in lines:
attrib = line.split(" = ")
if attrib[0] in attrib_list.keys():
VIDEO_CHECK.set(attrib_list[attrib[0]], eval(attrib[1]))
f.close()
print("*"*28)
print("* Checking camera settings *")
print("*"*28)
for attrib, index in attrib_list.items():
print(f"{attrib} = {VIDEO_CHECK.get(index)}")
VIDEO_CHECK.release()
def reset_settings():
if not os.path.exists("camera_settings.log"):
print("'camera_settings.log' does not exist!")
print("Verify your camera settings!")
return False
else:
VIDEO_CHECK = cv2.VideoCapture(0)
f = open("camera_settings.log", "r")
lines = f.read().split("\n")
for line in lines:
attrib = line.split(" = ")
if attrib[0] in attrib_list.keys():
VIDEO_CHECK.set(attrib_list[attrib[0]], eval(attrib[1]))
f.close()
VIDEO_CHECK.release()
return True