Невозможно изменить разрешение входного видео в opencv - PullRequest
0 голосов
/ 17 апреля 2019

Я не могу установить разрешение захвата видео в opencv. Он жестко запрограммирован на 1280 x 720. Я установил разрешение на 640 x 360. Но он по-прежнему показывает разрешение 1280 x 720.

106 cap = cv2.VideoCapture(RECORDED_FILE_DEMO)
107 if not cap.isOpened():
108     raise Exception("could not open RECORDED_FILE_DEMO")
109 
110 cap1 = cv2.VideoCapture(RECORDED_FILE_REF)
111 if not cap1.isOpened():
112     raise Exception("could not open RECORDED_FILE_REF")
113 cap1.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
114 cap1.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)
115 
116 
117 def show_frame():
118     #print("DEBUG:<show_frame> Im here")
119     cap.set(3, 640)
120     cap.set(4, 360)
121     ret, frame = cap.read()
122     frame = cv2.flip(frame, 1)
123     #frame = cv2.resize(frame,(1200,600))
124     width = cap.get(3)
125     height = cap.get(4)
126     print("DEBUG:<show_frame> width = ", width)
127     print("DEBUG:<show_frame> height = ", height)
128     cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
129     img = Image.fromarray(cv2image)
130     imgtk = ImageTk.PhotoImage(image=img)
131     label1.imgtk = imgtk
132     label1.configure(image=imgtk)
133     #while(pauseFlag == True):
134         #time.sleep(0.001)
135     label1.after(15, show_frame)

Вывод отображается как ширина = 1280, высота = 720

...