def _main():
    import sys
    app = QtGui.QApplication(sys.argv)
    cameraDevice = CameraDevice(mirrored=True)
    faceDetector = objectDetector("../data/haarcascade_frontalface_alt2.xml")
    enrollmentWidget = EnrollmentWidget(cameraDevice, faceDetector)
    enrollmentWidget.show()
    sys.exit(app.exec_())
def _main():
    import sys
    app = QtGui.QApplication(sys.argv)

    cameraDevice = CameraDevice(mirrored=True)
    faceDetector = objectDetector("./data/haarcascade_frontalface_alt2.xml")

    enrollmentWidget = EnrollmentWidget(cameraDevice, faceDetector)
    enrollmentWidget.show()

    appRet = app.exec_()

    # ugly workaround to force the release of cameraDevice =S
    import sip
    sip.delete(enrollmentWidget)

    sys.exit(appRet)
    def __init__(self, faceRecognizer, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setWindowTitle(self._APP_TITLE)

        self._centralWidget = QtGui.QWidget(self)
        self._horizontalLayout = QtGui.QHBoxLayout(self._centralWidget)

        self._leftPanelLayout = QtGui.QVBoxLayout()

        self._logo = QtGui.QLabel(self)
        self._logo.setPixmap(QtGui.QPixmap(self._LOGO_PATH))
        self._logo.setAlignment(QtCore.Qt.AlignCenter)
        self._leftPanelLayout.addWidget(self._logo)

        self._faceRecognizer = faceRecognizer
        self._settingsWidget = SettingsWidget(self._centralWidget)
        self._settingsWidget.users = self._faceRecognizer.users
        self._settingsWidget.securityTol = \
            int(self._faceRecognizer.securityTol*100)
        self._settingsWidget.techniques = self._faceRecognizer.techniquesNames
        self._onTechniqueChanged(self._settingsWidget.selectedTechnique)
        self._settingsWidget.newUserButtonClicked.connect(self._enrollmentMode)
        self._settingsWidget.removeUserButtonClicked.connect( \
            self._onRemoveUserButtonClicked)
        self._settingsWidget.securityTolChanged.connect( \
            self._onSecurityTolChanged)
        self._settingsWidget.techniqueChanged.connect( \
            self._onTechniqueChanged)
        self._leftPanelLayout.addWidget(self._settingsWidget)

        self._horizontalLayout.addLayout(self._leftPanelLayout)

        self._verticalLineSep = QtGui.QFrame(self._centralWidget)
        self._verticalLineSep.setFrameShape(QtGui.QFrame.VLine)
        self._verticalLineSep.setFrameShadow(QtGui.QFrame.Sunken)
        self._horizontalLayout.addWidget(self._verticalLineSep)

        self._cameraDevice = CameraDevice(mirrored=True)
        self._faceDetector = objectDetector(self._FACE_DETECTOR_PATH)

        self._rightPanelLayout = QtGui.QStackedLayout()

        self._faceRecognitionWidget = CameraWidget(self._cameraDevice, \
            self._centralWidget)
        self._faceRecognitionWidget.newFrame.connect( \
            self._faceRecognition)
        self._rightPanelLayout.addWidget(self._faceRecognitionWidget)

        self._enrollmentWidget = EnrollmentWidget(self._cameraDevice, \
            self._faceDetector, parent=self._centralWidget)
        self._enrollmentWidget.enrollmentConcluded.connect( \
            self._onEnrollmentConcluded)
        self._enrollmentWidget.enrollmentCanceled.connect( \
            self._faceRecognitionMode)
        self._rightPanelLayout.addWidget(self._enrollmentWidget)

        self._faceRecognitionMode()
        self._horizontalLayout.addLayout(self._rightPanelLayout)

        self.setCentralWidget(self._centralWidget)
    def __init__(self, faceRecognizer, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setWindowTitle(self._APP_TITLE)

        self._centralWidget = QtGui.QWidget(self)
        self._mainLayout = QtGui.QVBoxLayout(self._centralWidget)

        self._topLayout = QtGui.QHBoxLayout()

        self._leftPanelLayout = QtGui.QVBoxLayout()

        self._logo = QtGui.QLabel(self)
        self._logo.setPixmap(QtGui.QPixmap(self._LOGO_PATH))
        self._logo.setAlignment(QtCore.Qt.AlignCenter)
        self._leftPanelLayout.addWidget(self._logo)

        self._faceRecognizer = faceRecognizer
        self._settingsWidget = SettingsWidget(self._centralWidget)
        self._settingsWidget.users = self._faceRecognizer.users
        self._settingsWidget.securityTol = self._faceRecognizer.securityTol
        self._settingsWidget.techniques = self._faceRecognizer.techniquesNames
        self._settingsWidget.newUserButtonClicked.connect(self._enrollmentMode)
        self._settingsWidget.removeUserButtonClicked.connect( \
            self._onRemoveUserButtonClicked)
        self._settingsWidget.securityTolChanged.connect( \
            self._onSecurityTolChanged)
        self._settingsWidget.techniqueChanged.connect( \
            self._onTechniqueChanged)
        self._leftPanelLayout.addWidget(self._settingsWidget)

        self._topLayout.addLayout(self._leftPanelLayout)

        self._verticalLineSep = QtGui.QFrame(self._centralWidget)
        self._verticalLineSep.setFrameShape(QtGui.QFrame.VLine)
        self._verticalLineSep.setFrameShadow(QtGui.QFrame.Sunken)
        self._topLayout.addWidget(self._verticalLineSep)

        self._rightPanelLayout = QtGui.QStackedLayout()

        self._faceDetector = objectDetector(self._FACE_DETECTOR_PATH)

        self._cameraDevice = CameraDevice(mirrored=True, parent=self)
        self._faceRecognitionWidget = CameraWidget(self._cameraDevice, \
            self._centralWidget)
        self._faceRecognitionWidget.newFrame.connect(self._faceRecognition)
        self._rightPanelLayout.addWidget(self._faceRecognitionWidget)

        self._enrollmentWidget = EnrollmentWidget(self._cameraDevice, \
            self._faceDetector, parent=self._centralWidget)
        self._enrollmentWidget.enrollmentConcluded.connect( \
            self._onEnrollmentConcluded)
        self._enrollmentWidget.enrollmentCanceled.connect( \
            self._faceRecognitionMode)
        self._rightPanelLayout.addWidget(self._enrollmentWidget)

        self._topLayout.addLayout(self._rightPanelLayout)

        self._mainLayout.addLayout(self._topLayout)

        self._statusBar = QtGui.QStatusBar(self)
        self._statusBar.setSizeGripEnabled(False)

        self._modeStatusLabel = QtGui.QLabel(self._statusBar)
        self._statusBar.addPermanentWidget(self._modeStatusLabel)

        self._companyLink = QtGui.QLabel(self._statusBar)
        self._companyLink.setText(self._COMPANY_LINK)
        self._companyLink.setOpenExternalLinks(True)
        self._statusBar.addPermanentWidget(self._companyLink)

        self._authorLink = QtGui.QLabel(self._statusBar)
        self._authorLink.setText(self._AUTHOR_LINK)
        self._authorLink.setOpenExternalLinks(True)
        self._statusBar.addPermanentWidget(self._authorLink)

        self._horizontalLineSep = QtGui.QFrame(self._centralWidget)
        self._horizontalLineSep.setFrameShape(QtGui.QFrame.HLine)
        self._horizontalLineSep.setFrameShadow(QtGui.QFrame.Sunken)

        self._mainLayout.addWidget(self._horizontalLineSep)
        self._mainLayout.addWidget(self._statusBar)

        self.setCentralWidget(self._centralWidget)

        self._faceRecognitionMode()

        self._onTechniqueChanged(self._settingsWidget.selectedTechnique)