From 54a2da46706c70ab321c8a9507e9a1e58bbc5b30 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 18 Jun 2017 00:30:08 +0300 Subject: [PATCH] video setting - selector --- toxygen/menu.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/toxygen/menu.py b/toxygen/menu.py index 77fd1ea..ea323d6 100644 --- a/toxygen/menu.py +++ b/toxygen/menu.py @@ -823,13 +823,25 @@ class VideoSettings(CenteredWidget): self.input.setGeometry(QtCore.QRect(25, 30, 350, 30)) import cv2 self.devices = [] + self.frame_max_sizes = [] for i in range(10): v = cv2.VideoCapture(i) if v.isOpened(): + v.set(cv2.CAP_PROP_FRAME_WIDTH, 10000) + v.set(cv2.CAP_PROP_FRAME_HEIGHT, 10000) + + width = int(v.get(cv2.CAP_PROP_FRAME_WIDTH)) + height = int(v.get(cv2.CAP_PROP_FRAME_HEIGHT)) del v self.devices.append(i) + self.frame_max_sizes.append((width, height)) self.input.addItem('Device #' + str(i)) - self.input.setCurrentIndex(self.devices.index(settings.video['device'])) + self.size = QtWidgets.QComboBox(self) + self.size.setGeometry(QtCore.QRect(60, 30, 350, 30)) + self.input.currentIndexChanged.connect(self.selectionChanged) + index = self.devices.index(settings.video['device']) + if index + 1: + self.input.setCurrentIndex(index) def retranslateUi(self): self.setWindowTitle(QtWidgets.QApplication.translate("videoSettingsForm", "Video settings")) @@ -840,6 +852,22 @@ class VideoSettings(CenteredWidget): settings.video['device'] = self.devices[self.input.currentIndex()] settings.save() + def selectionChanged(self): + width, height = self.frame_max_sizes[self.input.currentIndex()] + self.size.clear() + dims = [ + (320, 240), + (640, 360), + (640, 480), + (720, 480), + (1280, 720), + (1920, 1080), + (2560, 1440) + ] + for w, h in dims: + if w <= width and h <= height: + self.size.addItem(str(w) + ' * ' + str(h)) + class PluginsSettings(CenteredWidget): """