-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdjectPara.py
More file actions
56 lines (41 loc) · 1.36 KB
/
AdjectPara.py
File metadata and controls
56 lines (41 loc) · 1.36 KB
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
"""
工具:使用带有滑块的窗口对相机参数进行实时调整
"""
import cv2
import numpy as np
from lib import Video
# def nothing(x):
# pass
def CaptureInit(
width: int = 640, height: int = 480, PI_MODE=True
) -> cv2.VideoCapture:
"摄像头配置和打开"
if PI_MODE:
capture = cv2.VideoCapture(0)
else:
capture = cv2.VideoCapture(0, cv2.CAP_DSHOW)
capture.set(cv2.CAP_PROP_FRAME_WIDTH, width)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
# fourcc = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')
# capture.set(cv2.CAP_PROP_FOURCC, fourcc)
# capture.set(cv2.CAP_PROP_BUFFERSIZE, 1)
# cv2.namedWindow('video', cv2.WINDOW_KEEPRATIO)
# cv2.setMouseCallback("video", getMouse)
return capture
if __name__ == "__main__":
cap = CaptureInit(PI_MODE=False)
video = Video.TrackWindow("video", "value", 50, 100)
Video.printVideoPara(cap)
while True:
contrast = video.getValue()
if contrast != cap.get(cv2.CAP_PROP_CONTRAST):
# print(cap.isOpened(), cap.get(cv2.CAP_PROP_CONTRAST), contrast)
cap.set(cv2.CAP_PROP_CONTRAST, contrast)
_, frame = cap.read()
video.show(frame)
content = cv2.waitKey(1) & 0xFF
if content == 27: # Esc
print("exit!")
break
cap.release()
cv2.destroyAllWindows()