Beispiel #1
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(733, 628)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(100, 570, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.video_widget = VideoWidget(Dialog)
        self.video_widget.setGeometry(QtCore.QRect(20, 20, 648, 486))
        self.video_widget.setObjectName("video_widget")
        self.video_widget.push_frame(self._frame)

        text = "W: %f<br />H: %f" % (self.w, self.h)
        self.measure_text = QtGui.QTextEdit(text, Dialog)
        self.measure_text.setGeometry(QtCore.QRect(540, 550, 151, 61))
        self.measure_text.setObjectName("measure_text")

        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(540, 520, 55, 18))
        self.label.setObjectName("label")
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(270, 540, 171, 21))
        self.label_2.setObjectName("label_2")

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
Beispiel #2
0
    def init_ui(self):
        self.setWindowTitle('LabelTool')
        self.center_window(1200, 800)
        self.init_menubar()
        self.init_statusbar()

        self.video_widget = VideoWidget(max_fps=50)
        self.annotation_widget = AnnotationWidget()

        self.hbox_layout = QHBoxLayout()
        self.hbox_layout.addWidget(self.video_widget, 3)
        self.hbox_layout.addWidget(self.annotation_widget, 1)

        self.central_widget = QWidget(self)
        self.central_widget.setLayout(self.hbox_layout)
        self.setCentralWidget(self.central_widget)
    def __init__(self, expression_to_neutral=False):
        super().__init__()

        self.expression_to_neutral = expression_to_neutral
        if self.expression_to_neutral:
            self.title = "From Expression to Neutral"
        else:
            self.title = "3DMM"
        self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        self.setFixedSize(1200, 700)

        self.camera = Camera()
        self.progress_bar = QProgressBar(self)
        self.count = 0

        self.toolbar = self.addToolBar('Main Window')
        # self.toolbar_emotions = self.addToolBar('Emotions')

        self.expression = "neutral"
        self.picture_taken = False
        self.bool_onclick = None
        self.portrait = None
        self.model = Model(None, self.expression, self,
                           self.expression_to_neutral)
        self.video_widget = VideoWidget(self.camera)
        self.right_label = RightLabel(self, self.model)
        self.main_widget = MainWidget(self.video_widget, self.right_label,
                                      self.camera)
        self.setCentralWidget(self.main_widget)

        self.model.progress_bar.connect(self.set_progress_bar,
                                        type=Qt.QueuedConnection)
        self.combo_box = QComboBox(self)

        self.initUI()
Beispiel #4
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(733, 628)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(100, 570, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.video_widget = VideoWidget(Dialog)
        self.video_widget.setGeometry(QtCore.QRect(20, 20, 648, 486))
        self.video_widget.setObjectName("video_widget")
        self.video_widget.push_frame(self._frame)
        
        text = "W: %f<br />H: %f" % (self.w, self.h)
        self.measure_text = QtGui.QTextEdit(text, Dialog)
        self.measure_text.setGeometry(QtCore.QRect(540, 550, 151, 61))
        self.measure_text.setObjectName("measure_text")
        
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(540, 520, 55, 18))
        self.label.setObjectName("label")
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(270, 540, 171, 21)) 
        self.label_2.setObjectName("label_2")

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
    def __init__(self, camera, main=False):
        super().__init__()
        self.title = "3DMM"
        self.main = main
        # self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        self.camera = camera

        if main:
            # self.camera = Camera(1, main, )
            self.showFullScreen()
        else:
            # self.camera = Camera(0)
            self.setGeometry(100, 100, 600, 500)

        self.video_widget = VideoWidget(self.camera)

        self.initUI()
class MainWidget(QWidget):

    def __init__(self, camera, main=False):
        super().__init__()
        self.title = "3DMM"
        self.main = main
        # self.setWindowIcon(QtGui.QIcon('images/1UP.ico'))
        self.camera = camera

        if main:
            # self.camera = Camera(1, main, )
            self.showFullScreen()
        else:
            # self.camera = Camera(0)
            self.setGeometry(100, 100, 600, 500)

        self.video_widget = VideoWidget(self.camera)

        self.initUI()

    def initUI(self):

        if self.main:
            self.video_widget.setFixedWidth(1000)
            self.video_widget.move(0, 200)
            self.video_widget.setAlignment(Qt.AlignCenter)
        h = QHBoxLayout()
        h.addWidget(self.video_widget)
        self.setLayout(h)

    def activate(self):
        self.video_widget.activate()
        if not self.main:
            self.show()

    def deactivate(self):
        self.hide()
        self.video_widget.deactivate()

    def closeEvent(self, event):
        self.camera.deactivate()
        self.main_widget.deactivate()
        event.accept()
Beispiel #7
0
class SaveDialog(object):
    def __init__(self, frame, sizes):
        self._frame = frame
        self.w, self.h = sizes

    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(733, 628)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(100, 570, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.video_widget = VideoWidget(Dialog)
        self.video_widget.setGeometry(QtCore.QRect(20, 20, 648, 486))
        self.video_widget.setObjectName("video_widget")
        self.video_widget.push_frame(self._frame)

        text = "W: %f<br />H: %f" % (self.w, self.h)
        self.measure_text = QtGui.QTextEdit(text, Dialog)
        self.measure_text.setGeometry(QtCore.QRect(540, 550, 151, 61))
        self.measure_text.setObjectName("measure_text")

        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(540, 520, 55, 18))
        self.label.setObjectName("label")
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(270, 540, 171, 21))
        self.label_2.setObjectName("label_2")

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(
            QtGui.QApplication.translate("Dialog", "Dialog", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.label.setText(
            QtGui.QApplication.translate("Dialog", "Measure:", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.label_2.setText(
            QtGui.QApplication.translate("Dialog",
                                         "Is image quality acceptable?", None,
                                         QtGui.QApplication.UnicodeUTF8))
Beispiel #8
0
class SaveDialog(object):
    
    def __init__(self, frame, sizes):
        self._frame = frame
        self.w, self.h = sizes
    
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(733, 628)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(100, 570, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.video_widget = VideoWidget(Dialog)
        self.video_widget.setGeometry(QtCore.QRect(20, 20, 648, 486))
        self.video_widget.setObjectName("video_widget")
        self.video_widget.push_frame(self._frame)
        
        text = "W: %f<br />H: %f" % (self.w, self.h)
        self.measure_text = QtGui.QTextEdit(text, Dialog)
        self.measure_text.setGeometry(QtCore.QRect(540, 550, 151, 61))
        self.measure_text.setObjectName("measure_text")
        
        self.label = QtGui.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(540, 520, 55, 18))
        self.label.setObjectName("label")
        self.label_2 = QtGui.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(270, 540, 171, 21)) 
        self.label_2.setObjectName("label_2")

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate("Dialog", "Measure:", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setText(QtGui.QApplication.translate("Dialog", "Is image quality acceptable?", None, QtGui.QApplication.UnicodeUTF8))
Beispiel #9
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 600)
        self.centralWidget = QtGui.QWidget(MainWindow)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.gridLayout = QtGui.QGridLayout(self.centralWidget)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.groupBox = QtGui.QGroupBox(self.centralWidget)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.verticalLayout = QtGui.QVBoxLayout(self.groupBox)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.video_widget = VideoWidget(self.groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.video_widget.sizePolicy().hasHeightForWidth())
        self.video_widget.setSizePolicy(sizePolicy)
        self.video_widget.setMinimumSize(QtCore.QSize(640, 480))
        self.video_widget.setBaseSize(QtCore.QSize(0, 0))
        self.video_widget.setObjectName(_fromUtf8("video_widget"))
        self.verticalLayout.addWidget(self.video_widget)
        self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
        self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_2.setMinimumSize(QtCore.QSize(200, 0))
        self.groupBox_2.setBaseSize(QtCore.QSize(0, 0))
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.class_name = QtGui.QTextEdit(self.groupBox_2)
        self.class_name.setGeometry(QtCore.QRect(10, 50, 161, 21))
        self.class_name.setObjectName(_fromUtf8("class_name"))
        self.label = QtGui.QLabel(self.groupBox_2)
        self.label.setGeometry(QtCore.QRect(10, 30, 81, 16))
        self.label.setObjectName(_fromUtf8("label"))
        self.show_mask = QtGui.QCheckBox(self.groupBox_2)
        self.show_mask.setGeometry(QtCore.QRect(10, 90, 101, 21))
        self.show_mask.setObjectName(_fromUtf8("show_mask"))
        self.threshold = QtGui.QSpinBox(self.groupBox_2)
        self.threshold.setGeometry(QtCore.QRect(10, 130, 52, 28))
        self.threshold.setMaximum(400)
        self.threshold.setProperty("value", 80)
        self.threshold.setObjectName(_fromUtf8("threshold"))
        self.label_2 = QtGui.QLabel(self.groupBox_2)
        self.label_2.setGeometry(QtCore.QRect(70, 130, 91, 21))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.groupBox_2, 0, 1, 1, 1)
        self.snap_button = QtGui.QPushButton(self.centralWidget)
        self.snap_button.setObjectName(_fromUtf8("snap_button"))
        self.gridLayout.addWidget(self.snap_button, 1, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QtGui.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menuBar.setObjectName(_fromUtf8("menuBar"))
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtGui.QToolBar(MainWindow)
        self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtGui.QStatusBar(MainWindow)
        self.statusBar.setObjectName(_fromUtf8("statusBar"))
        MainWindow.setStatusBar(self.statusBar)
        self.mainToolBar.addSeparator()

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Beispiel #10
0
class MainWindow(QtGui.QMainWindow):
    key_press = Signal(int)
    key_release = Signal(int)
    destroyed = Signal()

    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setupUi(self)

    def keyPressEvent(self, event):
        self.key_press.emit(event.key())

    def keyReleaseEvent(self, event):
        self.key_release.emit(event.key())

    def closeEvent(self, event):
        self.destroyed.emit()

    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 600)
        self.centralWidget = QtGui.QWidget(MainWindow)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.gridLayout = QtGui.QGridLayout(self.centralWidget)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.groupBox = QtGui.QGroupBox(self.centralWidget)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.verticalLayout = QtGui.QVBoxLayout(self.groupBox)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.video_widget = VideoWidget(self.groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.video_widget.sizePolicy().hasHeightForWidth())
        self.video_widget.setSizePolicy(sizePolicy)
        self.video_widget.setMinimumSize(QtCore.QSize(640, 480))
        self.video_widget.setBaseSize(QtCore.QSize(0, 0))
        self.video_widget.setObjectName(_fromUtf8("video_widget"))
        self.verticalLayout.addWidget(self.video_widget)
        self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
        self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_2.setMinimumSize(QtCore.QSize(200, 0))
        self.groupBox_2.setBaseSize(QtCore.QSize(0, 0))
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.class_name = QtGui.QTextEdit(self.groupBox_2)
        self.class_name.setGeometry(QtCore.QRect(10, 50, 161, 21))
        self.class_name.setObjectName(_fromUtf8("class_name"))
        self.label = QtGui.QLabel(self.groupBox_2)
        self.label.setGeometry(QtCore.QRect(10, 30, 81, 16))
        self.label.setObjectName(_fromUtf8("label"))
        self.show_mask = QtGui.QCheckBox(self.groupBox_2)
        self.show_mask.setGeometry(QtCore.QRect(10, 90, 101, 21))
        self.show_mask.setObjectName(_fromUtf8("show_mask"))
        self.threshold = QtGui.QSpinBox(self.groupBox_2)
        self.threshold.setGeometry(QtCore.QRect(10, 130, 52, 28))
        self.threshold.setMaximum(400)
        self.threshold.setProperty("value", 80)
        self.threshold.setObjectName(_fromUtf8("threshold"))
        self.label_2 = QtGui.QLabel(self.groupBox_2)
        self.label_2.setGeometry(QtCore.QRect(70, 130, 91, 21))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.groupBox_2, 0, 1, 1, 1)
        self.snap_button = QtGui.QPushButton(self.centralWidget)
        self.snap_button.setObjectName(_fromUtf8("snap_button"))
        self.gridLayout.addWidget(self.snap_button, 1, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QtGui.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menuBar.setObjectName(_fromUtf8("menuBar"))
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtGui.QToolBar(MainWindow)
        self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtGui.QStatusBar(MainWindow)
        self.statusBar.setObjectName(_fromUtf8("statusBar"))
        MainWindow.setStatusBar(self.statusBar)
        self.mainToolBar.addSeparator()

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(
            QtGui.QApplication.translate("MainWindow", "MainWindow", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.groupBox.setTitle(
            QtGui.QApplication.translate("MainWindow", "Preview", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.groupBox_2.setTitle(
            QtGui.QApplication.translate("MainWindow", "Data", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.label.setText(
            QtGui.QApplication.translate("MainWindow", "Class name", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.show_mask.setText(
            QtGui.QApplication.translate("MainWindow", "Show Mask", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.label_2.setText(
            QtGui.QApplication.translate("MainWindow", "Threshold", None,
                                         QtGui.QApplication.UnicodeUTF8))
        self.snap_button.setText(
            QtGui.QApplication.translate("MainWindow", "Snap", None,
                                         QtGui.QApplication.UnicodeUTF8))
Beispiel #11
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 600)
        self.centralWidget = QtGui.QWidget(MainWindow)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.gridLayout = QtGui.QGridLayout(self.centralWidget)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.groupBox = QtGui.QGroupBox(self.centralWidget)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.verticalLayout = QtGui.QVBoxLayout(self.groupBox)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.video_widget = VideoWidget(self.groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.video_widget.sizePolicy().hasHeightForWidth())
        self.video_widget.setSizePolicy(sizePolicy)
        self.video_widget.setMinimumSize(QtCore.QSize(640, 480))
        self.video_widget.setBaseSize(QtCore.QSize(0, 0))
        self.video_widget.setObjectName(_fromUtf8("video_widget"))
        self.verticalLayout.addWidget(self.video_widget)
        self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
        self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_2.setMinimumSize(QtCore.QSize(200, 0))
        self.groupBox_2.setBaseSize(QtCore.QSize(0, 0))
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.class_name = QtGui.QTextEdit(self.groupBox_2)
        self.class_name.setGeometry(QtCore.QRect(10, 50, 161, 21))
        self.class_name.setObjectName(_fromUtf8("class_name"))
        self.label = QtGui.QLabel(self.groupBox_2)
        self.label.setGeometry(QtCore.QRect(10, 30, 81, 16))
        self.label.setObjectName(_fromUtf8("label"))
        self.show_mask = QtGui.QCheckBox(self.groupBox_2)
        self.show_mask.setGeometry(QtCore.QRect(10, 90, 101, 21))
        self.show_mask.setObjectName(_fromUtf8("show_mask"))
        self.threshold = QtGui.QSpinBox(self.groupBox_2)
        self.threshold.setGeometry(QtCore.QRect(10, 130, 52, 28))
        self.threshold.setMaximum(400)
        self.threshold.setProperty("value", 80)
        self.threshold.setObjectName(_fromUtf8("threshold"))
        self.label_2 = QtGui.QLabel(self.groupBox_2)
        self.label_2.setGeometry(QtCore.QRect(70, 130, 91, 21))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.groupBox_2, 0, 1, 1, 1)
        self.snap_button = QtGui.QPushButton(self.centralWidget)
        self.snap_button.setObjectName(_fromUtf8("snap_button"))
        self.gridLayout.addWidget(self.snap_button, 1, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QtGui.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menuBar.setObjectName(_fromUtf8("menuBar"))
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtGui.QToolBar(MainWindow)
        self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtGui.QStatusBar(MainWindow)
        self.statusBar.setObjectName(_fromUtf8("statusBar"))
        MainWindow.setStatusBar(self.statusBar)
        self.mainToolBar.addSeparator()

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Beispiel #12
0
class MainWindow(QtGui.QMainWindow):
    key_press = Signal(int)
    key_release = Signal(int)
    destroyed = Signal()
    
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.setupUi(self)
        
    def keyPressEvent(self, event):
        self.key_press.emit(event.key())
        
    def keyReleaseEvent(self, event):
        self.key_release.emit(event.key())
        
    def closeEvent(self, event):
        self.destroyed.emit()
        
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 600)
        self.centralWidget = QtGui.QWidget(MainWindow)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.gridLayout = QtGui.QGridLayout(self.centralWidget)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.groupBox = QtGui.QGroupBox(self.centralWidget)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.verticalLayout = QtGui.QVBoxLayout(self.groupBox)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.video_widget = VideoWidget(self.groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.video_widget.sizePolicy().hasHeightForWidth())
        self.video_widget.setSizePolicy(sizePolicy)
        self.video_widget.setMinimumSize(QtCore.QSize(640, 480))
        self.video_widget.setBaseSize(QtCore.QSize(0, 0))
        self.video_widget.setObjectName(_fromUtf8("video_widget"))
        self.verticalLayout.addWidget(self.video_widget)
        self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
        self.groupBox_2 = QtGui.QGroupBox(self.centralWidget)
        self.groupBox_2.setMinimumSize(QtCore.QSize(200, 0))
        self.groupBox_2.setBaseSize(QtCore.QSize(0, 0))
        self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
        self.class_name = QtGui.QTextEdit(self.groupBox_2)
        self.class_name.setGeometry(QtCore.QRect(10, 50, 161, 21))
        self.class_name.setObjectName(_fromUtf8("class_name"))
        self.label = QtGui.QLabel(self.groupBox_2)
        self.label.setGeometry(QtCore.QRect(10, 30, 81, 16))
        self.label.setObjectName(_fromUtf8("label"))
        self.show_mask = QtGui.QCheckBox(self.groupBox_2)
        self.show_mask.setGeometry(QtCore.QRect(10, 90, 101, 21))
        self.show_mask.setObjectName(_fromUtf8("show_mask"))
        self.threshold = QtGui.QSpinBox(self.groupBox_2)
        self.threshold.setGeometry(QtCore.QRect(10, 130, 52, 28))
        self.threshold.setMaximum(400)
        self.threshold.setProperty("value", 80)
        self.threshold.setObjectName(_fromUtf8("threshold"))
        self.label_2 = QtGui.QLabel(self.groupBox_2)
        self.label_2.setGeometry(QtCore.QRect(70, 130, 91, 21))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.groupBox_2, 0, 1, 1, 1)
        self.snap_button = QtGui.QPushButton(self.centralWidget)
        self.snap_button.setObjectName(_fromUtf8("snap_button"))
        self.gridLayout.addWidget(self.snap_button, 1, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QtGui.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menuBar.setObjectName(_fromUtf8("menuBar"))
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtGui.QToolBar(MainWindow)
        self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtGui.QStatusBar(MainWindow)
        self.statusBar.setObjectName(_fromUtf8("statusBar"))
        MainWindow.setStatusBar(self.statusBar)
        self.mainToolBar.addSeparator()

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Preview", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_2.setTitle(QtGui.QApplication.translate("MainWindow", "Data", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate("MainWindow", "Class name", None, QtGui.QApplication.UnicodeUTF8))
        self.show_mask.setText(QtGui.QApplication.translate("MainWindow", "Show Mask", None, QtGui.QApplication.UnicodeUTF8))
        self.label_2.setText(QtGui.QApplication.translate("MainWindow", "Threshold", None, QtGui.QApplication.UnicodeUTF8))
        self.snap_button.setText(QtGui.QApplication.translate("MainWindow", "Snap", None, QtGui.QApplication.UnicodeUTF8))
Beispiel #13
0
class MainWindow(QMainWindow):

    def __init__(self):
        QMainWindow.__init__(self)
        self.init_ui()
        # menu actions
        self.action_open.triggered.connect(self.video_widget.open_file)
        self.action_save.triggered.connect(self.video_widget.save_annotation)
        self.action_export.triggered.connect(self.video_widget.export_video)
        # video widget signals
        self.video_widget.annotation_loaded.connect(
            self.annotation_widget.show_tubes)
        self.video_widget.frame_updated.connect(self.update_frame_id)
        self.video_widget.tube_annotated.connect(
            self.annotation_widget.add_tube)
        self.video_widget.export_progress_updated.connect(
            self.update_export_progress)
        # annotation widget signals
        self.annotation_widget.combobox_word.currentTextChanged.connect(
            self.video_widget.update_bbox_label)
        self.annotation_widget.tube_selected.connect(
            self.video_widget.jump_to_tube)
        self.annotation_widget.tube_deleted.connect(
            self.video_widget.del_tube)
        self.annotation_widget.tube_label_renamed.connect(
            self.video_widget.change_tube_label)
        # show the window
        self.show()

    def center_window(self, w, h):
        desktop = QDesktopWidget()
        screen_w = desktop.width()
        screen_h = desktop.height()
        self.setGeometry((screen_w - w) / 2, (screen_h - h) / 2, w, h)

    def init_ui(self):
        self.setWindowTitle('LabelTool')
        self.center_window(1200, 800)
        self.init_menubar()
        self.init_statusbar()

        self.video_widget = VideoWidget(max_fps=50)
        self.annotation_widget = AnnotationWidget()

        self.hbox_layout = QHBoxLayout()
        self.hbox_layout.addWidget(self.video_widget, 3)
        self.hbox_layout.addWidget(self.annotation_widget, 1)

        self.central_widget = QWidget(self)
        self.central_widget.setLayout(self.hbox_layout)
        self.setCentralWidget(self.central_widget)

    def init_menubar(self):
        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        menu_file = menubar.addMenu('&File')
        self.action_open = QAction('&Open', menubar)
        self.action_open.setShortcut('Ctrl+O')
        menu_file.addAction(self.action_open)
        self.action_save = QAction('&Save', menubar)
        self.action_save.setShortcut('Ctrl+S')
        menu_file.addAction(self.action_save)
        self.action_export = QAction('&Export', menubar)
        self.action_export.setShortcut('Ctrl+E')
        menu_file.addAction(self.action_export)

    def init_statusbar(self):
        statusbar = self.statusBar()
        self.label_frame_idx = QLabel()
        self.progressbar_export = QProgressBar()
        self.progressbar_export.setRange(0, 100)
        self.progressbar_export.setVisible(False)
        statusbar.addWidget(self.label_frame_idx)
        statusbar.addPermanentWidget(self.progressbar_export)

    @pyqtSlot(int)
    def update_frame_id(self, frame_id):
        total_num = self.video_widget.frame_cnt()
        self.label_frame_idx.setText(' Frame {}/{}'.format(frame_id, total_num))

    @pyqtSlot(int)
    def update_export_progress(self, progress):
        if not self.progressbar_export.isVisible():
            self.progressbar_export.setVisible(True)
        self.progressbar_export.setValue(progress)