【问题标题】:Unable to change the input video resolution in opencv无法在opencv中更改输入视频分辨率
【发布时间】:2019-04-17 15:32:48
【问题描述】:

我无法在 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)

输出显示为 width = 1280, height = 720

【问题讨论】:

    标签: python-3.x opencv video-capture


    【解决方案1】:

    也许您的相机不支持该分辨率。 例如,这里是 raspberry pi camera 支持的模式。

    【讨论】:

      猜你喜欢
      • 2021-03-02
      • 2014-05-15
      • 2016-03-27
      • 2020-06-30
      • 1970-01-01
      • 2013-04-29
      • 1970-01-01
      • 2020-11-14
      • 1970-01-01
      相关资源
      最近更新 更多