From df5a1a901a326d58fcf587c9f3b4da48eb9faabb Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sun, 18 Jun 2017 00:50:42 +0300 Subject: [PATCH] video settings --- toxygen/calls.py | 8 ++++---- toxygen/menu.py | 19 +++++++++++-------- toxygen/settings.py | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/toxygen/calls.py b/toxygen/calls.py index 0ad8fac..a651a26 100644 --- a/toxygen/calls.py +++ b/toxygen/calls.py @@ -199,11 +199,11 @@ class AV: return self._video_running = True + s = settings.Settings.get_instance() + self._video_width = s.video['width'] + self._video_height = s.video['height'] - self._video_width = 640 # TODO: use settings - self._video_height = 480 - - self._video = cv2.VideoCapture(settings.Settings.get_instance().video['device']) + self._video = cv2.VideoCapture(s.video['device']) self._video.set(cv2.CAP_PROP_FPS, 25) self._video.set(cv2.CAP_PROP_FRAME_WIDTH, self._video_width) self._video.set(cv2.CAP_PROP_FRAME_HEIGHT, self._video_height) diff --git a/toxygen/menu.py b/toxygen/menu.py index ea323d6..4bb5258 100644 --- a/toxygen/menu.py +++ b/toxygen/menu.py @@ -808,9 +808,9 @@ class VideoSettings(CenteredWidget): def initUI(self): self.setObjectName("videoSettingsForm") - self.resize(400, 100) - self.setMinimumSize(QtCore.QSize(400, 100)) - self.setMaximumSize(QtCore.QSize(400, 100)) + self.resize(400, 120) + self.setMinimumSize(QtCore.QSize(400, 120)) + self.setMaximumSize(QtCore.QSize(400, 120)) self.in_label = QtWidgets.QLabel(self) self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20)) settings = Settings.get_instance() @@ -819,8 +819,11 @@ class VideoSettings(CenteredWidget): font.setBold(True) font.setFamily(settings['font']) self.in_label.setFont(font) + self.video_size = QtWidgets.QComboBox(self) + self.video_size.setGeometry(QtCore.QRect(25, 70, 350, 30)) self.input = QtWidgets.QComboBox(self) self.input.setGeometry(QtCore.QRect(25, 30, 350, 30)) + self.input.currentIndexChanged.connect(self.selectionChanged) import cv2 self.devices = [] self.frame_max_sizes = [] @@ -836,9 +839,6 @@ class VideoSettings(CenteredWidget): self.devices.append(i) self.frame_max_sizes.append((width, height)) self.input.addItem('Device #' + str(i)) - 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) @@ -850,11 +850,14 @@ class VideoSettings(CenteredWidget): def closeEvent(self, event): settings = Settings.get_instance() settings.video['device'] = self.devices[self.input.currentIndex()] + text = self.video_size.currentText() + settings.video['width'] = int(text.split(' ')[0]) + settings.video['height'] = int(text.split(' ')[-1]) settings.save() def selectionChanged(self): width, height = self.frame_max_sizes[self.input.currentIndex()] - self.size.clear() + self.video_size.clear() dims = [ (320, 240), (640, 360), @@ -866,7 +869,7 @@ class VideoSettings(CenteredWidget): ] for w, h in dims: if w <= width and h <= height: - self.size.addItem(str(w) + ' * ' + str(h)) + self.video_size.addItem(str(w) + ' * ' + str(h)) class PluginsSettings(CenteredWidget): diff --git a/toxygen/settings.py b/toxygen/settings.py index c007d3a..9a1c439 100644 --- a/toxygen/settings.py +++ b/toxygen/settings.py @@ -47,7 +47,7 @@ class Settings(dict, Singleton): self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1, 'output': p.get_default_output_device_info()['index'] if output_devices else -1, 'enabled': input_devices and output_devices} - self.video = {'device': 0} + self.video = {'device': 0, 'width': 640, 'height': 480} @staticmethod def get_auto_profile():