video settings

This commit is contained in:
ingvar1995 2017-06-18 00:50:42 +03:00
parent 54a2da4670
commit df5a1a901a
3 changed files with 16 additions and 13 deletions

View File

@ -199,11 +199,11 @@ class AV:
return return
self._video_running = True 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 = cv2.VideoCapture(s.video['device'])
self._video_height = 480
self._video = cv2.VideoCapture(settings.Settings.get_instance().video['device'])
self._video.set(cv2.CAP_PROP_FPS, 25) 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_WIDTH, self._video_width)
self._video.set(cv2.CAP_PROP_FRAME_HEIGHT, self._video_height) self._video.set(cv2.CAP_PROP_FRAME_HEIGHT, self._video_height)

View File

@ -808,9 +808,9 @@ class VideoSettings(CenteredWidget):
def initUI(self): def initUI(self):
self.setObjectName("videoSettingsForm") self.setObjectName("videoSettingsForm")
self.resize(400, 100) self.resize(400, 120)
self.setMinimumSize(QtCore.QSize(400, 100)) self.setMinimumSize(QtCore.QSize(400, 120))
self.setMaximumSize(QtCore.QSize(400, 100)) self.setMaximumSize(QtCore.QSize(400, 120))
self.in_label = QtWidgets.QLabel(self) self.in_label = QtWidgets.QLabel(self)
self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20)) self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20))
settings = Settings.get_instance() settings = Settings.get_instance()
@ -819,8 +819,11 @@ class VideoSettings(CenteredWidget):
font.setBold(True) font.setBold(True)
font.setFamily(settings['font']) font.setFamily(settings['font'])
self.in_label.setFont(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 = QtWidgets.QComboBox(self)
self.input.setGeometry(QtCore.QRect(25, 30, 350, 30)) self.input.setGeometry(QtCore.QRect(25, 30, 350, 30))
self.input.currentIndexChanged.connect(self.selectionChanged)
import cv2 import cv2
self.devices = [] self.devices = []
self.frame_max_sizes = [] self.frame_max_sizes = []
@ -836,9 +839,6 @@ class VideoSettings(CenteredWidget):
self.devices.append(i) self.devices.append(i)
self.frame_max_sizes.append((width, height)) self.frame_max_sizes.append((width, height))
self.input.addItem('Device #' + str(i)) 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']) index = self.devices.index(settings.video['device'])
if index + 1: if index + 1:
self.input.setCurrentIndex(index) self.input.setCurrentIndex(index)
@ -850,11 +850,14 @@ class VideoSettings(CenteredWidget):
def closeEvent(self, event): def closeEvent(self, event):
settings = Settings.get_instance() settings = Settings.get_instance()
settings.video['device'] = self.devices[self.input.currentIndex()] 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() settings.save()
def selectionChanged(self): def selectionChanged(self):
width, height = self.frame_max_sizes[self.input.currentIndex()] width, height = self.frame_max_sizes[self.input.currentIndex()]
self.size.clear() self.video_size.clear()
dims = [ dims = [
(320, 240), (320, 240),
(640, 360), (640, 360),
@ -866,7 +869,7 @@ class VideoSettings(CenteredWidget):
] ]
for w, h in dims: for w, h in dims:
if w <= width and h <= height: if w <= width and h <= height:
self.size.addItem(str(w) + ' * ' + str(h)) self.video_size.addItem(str(w) + ' * ' + str(h))
class PluginsSettings(CenteredWidget): class PluginsSettings(CenteredWidget):

View File

@ -47,7 +47,7 @@ class Settings(dict, Singleton):
self.audio = {'input': p.get_default_input_device_info()['index'] if input_devices else -1, 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, 'output': p.get_default_output_device_info()['index'] if output_devices else -1,
'enabled': input_devices and output_devices} 'enabled': input_devices and output_devices}
self.video = {'device': 0} self.video = {'device': 0, 'width': 640, 'height': 480}
@staticmethod @staticmethod
def get_auto_profile(): def get_auto_profile():