def __init__(self, img, title): QtWidgets.QMainWindow.__init__(self) self.setWindowTitle(title) widget = QtWidgets.QWidget() self.setCentralWidget(widget) layout = QtWidgets.QVBoxLayout(widget) qimg = QtGui.QImage(ImageQt(img)) pixmap = QtGui.QPixmap(qimg) label = QtWidgets.QLabel() label.setPixmap(pixmap) label.adjustSize() layout.addWidget(label) self.resize(label.width(), label.height())
def show_qt(img, title=None): from matplotlib.backends.backend_qt5 import QtCore, QtGui, QtWidgets from PIL.ImageQt import ImageQt import sys # Set up window class ImageWindow(QtWidgets.QMainWindow): def __init__(self, img, title): QtWidgets.QMainWindow.__init__(self) self.setWindowTitle(title) widget = QtWidgets.QWidget() self.setCentralWidget(widget) layout = QtWidgets.QVBoxLayout(widget) qimg = QtGui.QImage(ImageQt(img)) pixmap = QtGui.QPixmap(qimg) label = QtWidgets.QLabel() label.setPixmap(pixmap) label.adjustSize() layout.addWidget(label) self.resize(label.width(), label.height()) app = QtWidgets.QApplication([]) windows= [] for img_, title_ in _show_helper(img, title): window = ImageWindow(img_, title_) window.show() windows.append(window) app.exec_()
def record(audio_source: int, video_source_id: int): """Runs all of the recorders to check that everything works correctly.""" audio_device = sd.query_devices()[audio_source] # Create capture nodes video_source = DeviceVideoSource(video_source_id) audio_source = DeviceAudioSource(audio_device['max_input_channels'], audio_device['default_samplerate'], audio_source) keyboard_source = KeyboardSource() mouse_source = MouseSource() gaze_detector = GazeDetector(video_source) speech_detector = SpeechDetector(audio_source) mouse_compressor = MouseCompressor(mouse_source) engagement_estimator = EngagementEstimator(gaze_detector, speech_detector) store = CSVStore(f'data/session-{datetime.now().strftime("%m-%d-%H-%M")}', mouse_compressor, keyboard_source, engagement_estimator) graph_view = GraphView(mouse_compressor, keyboard_source, engagement_estimator) qapp = QtWidgets.QApplication.instance() if not qapp: qapp = QtWidgets.QApplication(sys.argv) store.start() graph_view.start() exit_code = qapp.exec_() graph_view.stop() store.stop() sys.exit(exit_code)