Ejemplo n.º 1
0
class Display(QtGui.QMainWindow):
    """ This is the main Thread 
    Starts the other threads (eye tracking, video capture/recording)
    """
    enabled = True
    fc = 0
    last_t = time.time()
    def __init__(self, fps, parent=None):
        self.fps = 29
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Display()
        self.ui.setupUi(self)

        # add the guys we need for displaying frames 
        self.ui.scene = QtGui.QGraphicsScene(self.ui.layout)
        self.ui.view = QtGui.QGraphicsView(self.ui.scene)
        self.ui.layout.addWidget(self.ui.view)
        self.ui.image = QtGui.QGraphicsPixmapItem()
        self.ui.scene.addItem(self.ui.image)
        self.ui.view.centerOn(self.ui.image)

        self.vcr = VideoRecorder(fps)
        self.vcr.plug_in(self)
        self.vcr.start()

        self.connect( self.vcr, QtCore.SIGNAL("update(QString)"), self.update )

    def update(self):
        """ update display with frame from eye tracker """
        frame = self.vcr.frame
        height, width = frame.shape
        im = QtGui.QImage(frame.flatten(), width, height, QtGui.QImage.Format_Indexed8)
        pix = QtGui.QPixmap.fromImage(im)
        self.ui.image.setPixmap(pix)
        
    def closeEvent(self, event):
        self.vcr.close()
Ejemplo n.º 2
0
    def __init__(self, fps, parent=None):
        self.fps = 29
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Display()
        self.ui.setupUi(self)

        # add the guys we need for displaying frames 
        self.ui.scene = QtGui.QGraphicsScene(self.ui.layout)
        self.ui.view = QtGui.QGraphicsView(self.ui.scene)
        self.ui.layout.addWidget(self.ui.view)
        self.ui.image = QtGui.QGraphicsPixmapItem()
        self.ui.scene.addItem(self.ui.image)
        self.ui.view.centerOn(self.ui.image)

        self.vcr = VideoRecorder(fps)
        self.vcr.plug_in(self)
        self.vcr.start()

        self.connect( self.vcr, QtCore.SIGNAL("update(QString)"), self.update )