我无法在opencv中设置视频捕获分辨率。它被硬编码为1280 x720。我将分辨率设置为640 x360。但是,它仍然显示分辨率为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