Пример #1
0
 def __init__(self):
     QMainWindow.__init__(self)
     self.ui = loadUi('forms/mainwindow.ui', self)
     # self.ui = Ui_MainWindow()
     # self.ui.setupUi(self)
     self.input_name = None
     self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)
     self.videoWidget = VideoWidget(self)
     self.detector = CellDetector()
     layout = QVBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget(self.videoWidget)
     self.ui.videoFrame.setLayout(layout)
     self.ui.playButton.setEnabled(False)
     self.ui.playButton.setIcon(self.style().standardIcon(
         QStyle.SP_MediaPlay))
     self.ui.playButton.clicked.connect(self.play)
     self.ui.openButton.clicked.connect(self.openFile)
     self.ui.saveButton.clicked.connect(self.saveFile)
     self.ui.saveButton.setEnabled(False)
     self.ui.timeSlider.sliderMoved.connect(self.setPosition)
     self.ui.modeCheckBox.stateChanged.connect(self.switchMode)
     self.ui.statusbar: QStatusBar
     self.ui.statusbar.showMessage("Init Model ...")
     # self.ui.statusbar.setLayout()
     self.mediaPlayer.setVideoOutput(self.videoWidget.videoSurface())
     self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)
     self.mediaPlayer.positionChanged.connect(self.positionChanged)
     self.mediaPlayer.durationChanged.connect(self.durationChanged)
     self.mediaPlayer.setMuted(True)
     # shortcut
     QShortcut(QKeySequence('Space'), self).activated.connect(self.play)
Пример #2
0
    def __init__(self):
        """Class constructor that sets up the window layout and allocates attributes"""
        super().__init__()
        self.title = 'Database Manager - Take Photo'
        self.setFixedSize(600,400)

        self.face_recognizer = FaceRecogniser()
        self.video_widget = VideoWidget(self.face_recognizer)
        h = QHBoxLayout()
        h.addWidget(self.video_widget)
        self.setLayout(h)
Пример #3
0
    def createLayout(self):
        """ Create the layout of the window. """
        centralWidget = QtGui.QWidget(self)
        self.mainLayout = QtGui.QVBoxLayout(centralWidget)
        self.videoWidget = VideoWidget()
        self.surface = self.videoWidget.videoSurface()
        self.videoWidget.setStringStartPosition(
            (self.videoWidget.size().width() * 0.9,
             self.videoWidget.size().height()))

        self.controlLayout = QtGui.QVBoxLayout()
        self.createInfoInterface()

        self.creatBasicControls()
        self.createOptionControls()

        self.mainLayout.addWidget(self.videoWidget)
        self.mainLayout.insertLayout(1, self.controlLayout)

        self.setCentralWidget(centralWidget)
        self.treatmentComboBox.currentIndexChanged.emit(0)
Пример #4
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setWindowTitle('DD监控室')
        self.resize(1600, 900)
        self.maximumToken = True
        if os.path.exists(r'utils/config.json'):
            self.config = json.loads(open(r'utils/config.json').read())
            while len(self.config['player']) < 9:
                self.config['player'].append(0)
        else:
            self.config = {
                'roomid': [21463219, 21501730, 21096962, 21449068],
                'layout': [(0, 0, 1, 1), (0, 1, 1, 1), (1, 0, 1, 1), (1, 1, 1, 1)],
                'player': [21463219, 21501730, 21096962, 21449068, 0, 0, 0, 0, 0],
                'quality': [80] * 9,
                'muted': [1] * 9,
                'volume': [25] * 9,
                'danmu': [True] * 9,
                'translator': [True] * 9,
                'globalVolume': 25,
                'control': True,
            }
        mainWidget = QWidget()
        self.setCentralWidget(mainWidget)
        self.mainLayout = QGridLayout(mainWidget)
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.layoutSettingPanel = LayoutSettingPanel()
        self.layoutSettingPanel.layoutConfig.connect(self.changeLayout)
        self.version = Version()

        self.videoWidgetList = []
        for i in range(9):
            self.videoWidgetList.append(VideoWidget(i))
            self.videoWidgetList[i].mutedChanged.connect(self.mutedChanged)
            self.videoWidgetList[i].volumeChanged.connect(self.volumeChanged)
            self.videoWidgetList[i].addMedia.connect(self.addMedia)
            self.videoWidgetList[i].deleteMedia.connect(self.deleteMedia)
            self.videoWidgetList[i].exchangeMedia.connect(self.exchangeMedia)
            self.videoWidgetList[i].setDanmu.connect(self.setDanmu)
            self.videoWidgetList[i].setTranslator.connect(self.setTranslator)
            self.videoWidgetList[i].changeQuality.connect(self.setQuality)
            self.videoWidgetList[i].popWindow.connect(self.popWindow)
            self.videoWidgetList[i].mediaMute(self.config['muted'][i], emit=False)
            self.videoWidgetList[i].player.setVolume(self.config['volume'][i])
            self.videoWidgetList[i].slider.setValue(self.config['volume'][i])
            self.videoWidgetList[i].quality = self.config['quality'][i]
            if self.config['danmu'][i]:
                self.videoWidgetList[i].textBrowser.show()
            else:
                self.videoWidgetList[i].textBrowser.hide()
            if self.config['translator'][i]:
                self.videoWidgetList[i].translator.show()
            else:
                self.videoWidgetList[i].translator.hide()
        self.popVideoWidgetList = []  # 置顶的悬浮窗
        for i in range(9):
            self.popVideoWidgetList.append(VideoWidget(i, True, '悬浮窗', [1280, 720]))
        self.setPlayer()


        self.controlBar = QToolBar()
        self.addToolBar(self.controlBar)
        self.controlBar.show() if self.config['control'] else self.controlBar.hide()

        self.globalPlayToken = True
        self.play = PushButton(self.style().standardIcon(QStyle.SP_MediaPause))
        self.play.clicked.connect(self.globalMediaPlay)
        self.controlBar.addWidget(self.play)
        self.reload = PushButton(self.style().standardIcon(QStyle.SP_BrowserReload))
        self.reload.clicked.connect(self.globalMediaReload)
        self.controlBar.addWidget(self.reload)
        self.globalMuteToken = False
        self.volume = PushButton(self.style().standardIcon(QStyle.SP_MediaVolume))
        self.volume.clicked.connect(self.globalMediaMute)
        self.controlBar.addWidget(self.volume)
        self.slider = Slider()
        self.slider.setValue(self.config['globalVolume'])
        self.slider.value.connect(self.globalSetVolume)
        self.controlBar.addWidget(self.slider)
        self.stop = PushButton(self.style().standardIcon(QStyle.SP_DialogCancelButton))
        self.stop.clicked.connect(self.globalMediaStop)
        self.controlBar.addWidget(self.stop)

        self.addButton = QPushButton('+')
        self.addButton.setFixedSize(160, 104)
        self.addButton.setStyleSheet('border:3px dotted #EEEEEE')
        self.addButton.setFont(QFont('Arial', 24, QFont.Bold))

        self.controlBar.addWidget(self.addButton)
        self.controlBar.addWidget(QLabel())

        self.scrollArea = ScrollArea()
        self.scrollArea.setStyleSheet('border-width:0px')
        self.scrollArea.setMinimumHeight(111)
        self.scrollArea.setMinimumWidth(1000)
        self.controlBar.addWidget(self.scrollArea)
        self.liverPanel = LiverPanel(self.config['roomid'])
        self.liverPanel.addLiverRoomWidget.getHotLiver.start()
        self.liverPanel.addToWindow.connect(self.addCoverToPlayer)
        self.scrollArea.setWidget(self.liverPanel)
        self.addButton.clicked.connect(self.liverPanel.openLiverRoomPanel)

        self.optionMenu = self.menuBar().addMenu('设置')
        self.controlBarToken = self.config['control']
        layoutConfigAction = QAction('布局方式', self, triggered=self.openLayoutSetting)
        self.optionMenu.addAction(layoutConfigAction)
        controlPanelAction = QAction('显示/隐藏控制条', self, triggered=self.openControlPanel)
        self.optionMenu.addAction(controlPanelAction)
        self.fullScreenAction = QAction('全屏显示 (Esc退出)', self, triggered=self.fullScreen)
        self.optionMenu.addAction(self.fullScreenAction)

        self.versionMenu = self.menuBar().addMenu('版本')
        versionAction = QAction('当前版本', self, triggered=self.openVersion)
        self.versionMenu.addAction(versionAction)
Пример #5
0
    def create_videos_list(self):
        self.create_videos_container()

        for video_file in self.video_files:
            video_widget = VideoWidget(self, video_file)
            self.videos_widget.add_video(video_widget)
Пример #6
0
except ImportError:
    qdark_present = False

from MainWindow import MainWindow
from VideoWidget import VideoWidget
from DialogWidget import DialogWidget
from FaceRecogniser import FaceRecogniser
from Speech_DialogManager import Speech_DialogManager

if __name__ == '__main__':
    app = QApplication(sys.argv)
    if qdark_present:  # load qdarkstyle if present
        app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())

    face_recon = FaceRecogniser()
    speechManager = Speech_DialogManager()
    video = VideoWidget(face_recon)
    dialog = DialogWidget(speechManager)

    window = MainWindow(video, dialog)  # The view controller / view (GUI)

    # Qt Signals and slots connection
    video.face_recogniser.person_identified.connect(window.activate_dialog,
                                                    type=Qt.QueuedConnection)
    dialog.speech_dialog_manager.finished.connect(window.activate_video,
                                                  type=Qt.QueuedConnection)

    # Starts with the Face Recognition
    window.activate_video()

    sys.exit(app.exec_())
Пример #7
0
    def __init__(self, args):
        TouchApplication.__init__(self, args)

        # create the empty main window
        self.w = TouchWindow("Run JetsonEV")

        self.relative_path = os.path.dirname(os.path.realpath(__file__))
        self.script = os.path.join(self.relative_path, 'Run_car.py')
        self.grid = QGridLayout()
        self.grid.setSpacing(0)
        self.process = QProcess()
        self.process.readyReadStandardOutput.connect(self.stdoutReady)
        self.process.readyReadStandardError.connect(self.stderrReady)

        self.play_btn = ShadowButton(os.path.join(self.relative_path, 'start'))
        self.play_btn.setText("Start")
        self.play_btn.clicked.connect(self.start_script)
        self.grid.addWidget(self.play_btn, 0, 0, 1, 1)
        self.grid.setColumnStretch(0, 1.25)

        self.imu_box = QCheckBox('IMU')
        self.imu_box.setChecked(True)
        self.camera_box = QCheckBox('Cam')
        self.camera_box.setChecked(False)
        self.lidar_box = QCheckBox('Lidar')
        self.lidar_box.setChecked(False)
        self.grid.addWidget(self.imu_box, 0, 1, 1, 1)
        self.grid.setColumnStretch(1, 1)
        self.grid.addWidget(self.camera_box, 0, 2, 1, 1)
        self.grid.setColumnStretch(2, 1)
        self.grid.addWidget(self.lidar_box, 0, 3, 1, 1)
        self.grid.setColumnStretch(3, 1.5)
        self.grid.setAlignment(Qt.AlignCenter)

        self.stop_btn = ShadowButton(os.path.join(self.relative_path, 'stop'))
        self.stop_btn.setText("Stop")
        self.stop_btn.clicked.connect(self.stop_script)
        self.grid.addWidget(self.stop_btn, 0, 4, 1, 1)
        self.grid.setRowStretch(1, 4)

        self.console_output = QPlainTextEdit()
        self.console_output.setReadOnly(True)
        console_style = "QPlainTextEdit {" \
                        "background-color: black;" \
                        "color: white;" \
                        "}"
        self.console_output.setFocusPolicy(Qt.NoFocus)
        self.console_output.setFrameStyle(3)
        self.console_output.setStyleSheet(console_style)

        self.grid.addWidget(self.console_output, 1, 0, 1, 5)

        self.w.centralWidget.setLayout(self.grid)
        self.w.centralWidget.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.w.centralWidget, event)
        self.w.centralWidget.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.w.centralWidget, event)
        self.w.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.w, event)
        self.w.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.w, event)
        self.play_btn.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.play_btn, event)
        self.play_btn.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.play_btn, event)
        self.stop_btn.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.stop_btn, event)
        self.stop_btn.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.stop_btn, event)

        self.imu_box.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.imu_box, event)
        self.imu_box.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.imu_box, event)
        self.camera_box.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.camera_box, event)
        self.camera_box.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.camera_box, event)
        self.lidar_box.keyReleaseEvent = lambda event: self.filter_out_arrow_release_keys(
            self.lidar_box, event)
        self.lidar_box.keyPressEvent = lambda event: self.filter_out_arrow_press_keys(
            self.lidar_box, event)

        self.xbox_controller = XBoxInput()
        self.xbox_controller.cycle_right.connect(self.cycle_right)
        self.xbox_controller.cycle_left.connect(self.cycle_left)

        self.speed_widget = SpeedWidget()
        self.grid.addWidget(self.speed_widget, 1, 0, 1, 5)
        self.speed_widget.hide()

        self.imu_widget = IMUWidget()
        self.grid.addWidget(self.imu_widget, 1, 0, 1, 5)
        self.imu_widget.hide()

        self.camera_widget = VideoWidget()
        self.grid.addWidget(self.camera_widget, 1, 0, 1, 5)
        self.camera_widget.hide()

        self.lidar_widget = LidarWidget()
        self.grid.addWidget(self.lidar_widget, 1, 0, 1, 5)
        self.lidar_widget.hide()

        self.widgets_to_show = []
        self.show_widget_index = 0
        self.w.show()
        self.aboutToQuit.connect(self.xbox_controller.xbox_controller.close)
        self.exec_()