Esempio n. 1
0
    def __init__(self,
                 port='/dev/ttyS3',
                 baudRate=57600,
                 address=0xFFFFFFFF,
                 password=0xFFFFFFFF):
        super().__init__()
        self.port = port
        self.baudRate = baudRate
        self.address = address
        self.password = password
        try:
            self.fingerprintObj = PyFingerprint(port, baudRate, address,
                                                password)
            # self.fingerprintObj.verifyPassword()
        except:
            self.fingerprintObj = False

        self.timerDownloadFGPimage = QTimer()
        self.timerDownloadFGPimage.timeout.connect(self.ThreadDownloadFGPimage)

        self.timerGetFGPfeature = QTimer()
        self.timerGetFGPfeature.timeout.connect(self.ThreadGetFGPfeature)

        self.lstIDvaVanTay = []
        self.viTriDaChonChuaLuu = []
        self.FlagFGPfree = True
        self.__FlagLockFGPsensor = False
Esempio n. 2
0
    def GetFGPfeature(self):
        if (self.__FlagLockFGPsensor):
            return
        self.__FlagLockFGPsensor = True
        try:
            if (type(self.fingerprintObj) is not bool):
                if (self.fingerprintObj.readImage()):
                    self.SignalHandPushed.emit()
                    self.fingerprintObj.convertImage(0x01)
                    theSame = self.fingerprintObj.searchTemplate()
                    if (theSame[0] == -1):
                        lstFGPfeature = self.fingerprintObj.downloadCharacteristics(
                            0x01)
                        self.fingerprintObj.storeTemplate()
                        lstFGPfeatureStrElem = [
                            str(elem) for elem in lstFGPfeature
                        ]
                        FGPfeatureString = ",".join(lstFGPfeatureStrElem)
                        self.SignalFGPget.emit(FGPfeatureString)

                    else:
                        self.SignalFGPputOnIsTheSame.emit()

            else:
                self.fingerprintObj = PyFingerprint(self.port, self.baudRate,
                                                    self.address,
                                                    self.password)
                self.fingerprintObj.verifyPassword()

        except:
            self.__FlagLockFGPsensor = False
            self.fingerprintObj = False
        self.__FlagLockFGPsensor = False
Esempio n. 3
0
 def DownloadFGPimage(self):
     try:
         if (type(self.fingerprintObj) is not bool):
             if (self.fingerprintObj.readImage()):
                 imageName = datetime.now().strftime("%H_%M_%S") + ".bmp"
                 imageDir = os.getcwd() + "/" + imageName
                 self.fingerprintObj.downloadImage(imageDir)
                 self.SignalDowloadedImage.emit(imageName)
         else:
             self.fingerprintObj = PyFingerprint(self.port, self.baudRate,
                                                 self.address,
                                                 self.password)
             self.fingerprintObj.verifyPassword()
     except:
         self.fingerprintObj = False
     self.FlagFGPfree = True
Esempio n. 4
0
 def __init__(self, port = '/dev/ttyS3', baudRate = 57600, address = 0xFFFFFFFF, password = 0xFFFFFFFF):
     super().__init__()
     self.port = port
     self.baudRate = baudRate
     self.address = address
     self.password = password
     try:
         self.fingerprintObj = PyFingerprint(port, baudRate, address, password)
         # self.fingerprintObj.verifyPassword()
     except:
         self.fingerprintObj = False
     
     self.TimerThemVanTay = QTimer()
     self.TimerThemVanTay.timeout.connect(self.ThemVanTay)
     self.TimerLayVanTayDangNhap = QTimer()
     self.TimerLayVanTayDangNhap.timeout.connect(self.ThreadLayVanTayDangNhap)
     self.FlagFGPfree = True
Esempio n. 5
0
 def ThemVanTay(self):
     try:
         if(type(self.fingerprintObj) is not bool):
             if(self.fingerprintObj.readImage()):
                 self.SignalHandPushed.emit()
                 self.fingerprintObj.convertImage(0x01)
                 self.fingerprintObj.readImage()
                 self.fingerprintObj.convertImage(0x02)
                 if(self.fingerprintObj.compareCharacteristics() > 0):
                     self.fingerprintObj.storeTemplate(1, 0x01)
                     self.SignalNewFGPadded.emit()
                     self.TatThemVanTay()
         else:
             self.SignalNotFGPsensor.emit()
             self.fingerprintObj = PyFingerprint(self.port, self.baudRate, self.address, self.password)
             self.fingerprintObj.verifyPassword()
     except:
         self.SignalNotFGPsensor.emit()
         self.fingerprintObj = False
Esempio n. 6
0
class Fingerprint(QObject):
    SignalNewFGPadded = pyqtSignal(int, list)
    SignalRecognizedFGP = pyqtSignal(int)
    SignalFGPnotFind = pyqtSignal()
    SignalHandPushed = pyqtSignal()
    SignalDowloadedImage = pyqtSignal(str)
    SignalFGPget = pyqtSignal(str)
    SignalFGPputOnIsTheSame = pyqtSignal()

    def __init__(self,
                 port='/dev/ttyS3',
                 baudRate=57600,
                 address=0xFFFFFFFF,
                 password=0xFFFFFFFF):
        super().__init__()
        self.port = port
        self.baudRate = baudRate
        self.address = address
        self.password = password
        try:
            self.fingerprintObj = PyFingerprint(port, baudRate, address,
                                                password)
            # self.fingerprintObj.verifyPassword()
        except:
            self.fingerprintObj = False

        self.timerDownloadFGPimage = QTimer()
        self.timerDownloadFGPimage.timeout.connect(self.ThreadDownloadFGPimage)

        self.timerGetFGPfeature = QTimer()
        self.timerGetFGPfeature.timeout.connect(self.ThreadGetFGPfeature)

        self.lstIDvaVanTay = []
        self.viTriDaChonChuaLuu = []
        self.FlagFGPfree = True
        self.__FlagLockFGPsensor = False

    def ThreadGetFGPfeature(self):
        thread = threading.Thread(target=self.GetFGPfeature)
        thread.start()

    def StartGetFGP(self):
        self.timerGetFGPfeature.start(1000)

    def StopGetFGP(self):
        self.timerGetFGPfeature.stop()

    # def StartDownloadImage(self):
    #     self.timerDownloadFGPimage.start(1000)

    # def StopDownloadImage(self):
    #     self.timerDownloadFGPimage.stop()

    def ThreadDownloadFGPimage(self):
        if (self.FlagFGPfree):
            self.FlagFGPfree = False
            thread = threading.Thread(target=self.GetFGPfeature,
                                      args=(),
                                      daemon=True)
            thread.start()

    def DownloadFGPimage(self):
        try:
            if (type(self.fingerprintObj) is not bool):
                if (self.fingerprintObj.readImage()):
                    imageName = datetime.now().strftime("%H_%M_%S") + ".bmp"
                    imageDir = os.getcwd() + "/" + imageName
                    self.fingerprintObj.downloadImage(imageDir)
                    self.SignalDowloadedImage.emit(imageName)
            else:
                self.fingerprintObj = PyFingerprint(self.port, self.baudRate,
                                                    self.address,
                                                    self.password)
                self.fingerprintObj.verifyPassword()
        except:
            self.fingerprintObj = False
        self.FlagFGPfree = True

    def ClearFGPfeatureSaveOnSensor(self):
        try:
            self.fingerprintObj.clearDatabase()
        except:
            pass

    def GetFGPfeature(self):
        if (self.__FlagLockFGPsensor):
            return
        self.__FlagLockFGPsensor = True
        try:
            if (type(self.fingerprintObj) is not bool):
                if (self.fingerprintObj.readImage()):
                    self.SignalHandPushed.emit()
                    self.fingerprintObj.convertImage(0x01)
                    theSame = self.fingerprintObj.searchTemplate()
                    if (theSame[0] == -1):
                        lstFGPfeature = self.fingerprintObj.downloadCharacteristics(
                            0x01)
                        self.fingerprintObj.storeTemplate()
                        lstFGPfeatureStrElem = [
                            str(elem) for elem in lstFGPfeature
                        ]
                        FGPfeatureString = ",".join(lstFGPfeatureStrElem)
                        self.SignalFGPget.emit(FGPfeatureString)

                    else:
                        self.SignalFGPputOnIsTheSame.emit()

            else:
                self.fingerprintObj = PyFingerprint(self.port, self.baudRate,
                                                    self.address,
                                                    self.password)
                self.fingerprintObj.verifyPassword()

        except:
            self.__FlagLockFGPsensor = False
            self.fingerprintObj = False
        self.__FlagLockFGPsensor = False
Esempio n. 7
0
class Fingerprint(QObject):
    SignalNewFGPadded = pyqtSignal()
    SignalRecognizedFGP = pyqtSignal()
    SignalFGPnotFind = pyqtSignal()
    SignalHandPushed = pyqtSignal()
    SignalNotFGPsensor = pyqtSignal()
    def __init__(self, port = '/dev/ttyS3', baudRate = 57600, address = 0xFFFFFFFF, password = 0xFFFFFFFF):
        super().__init__()
        self.port = port
        self.baudRate = baudRate
        self.address = address
        self.password = password
        try:
            self.fingerprintObj = PyFingerprint(port, baudRate, address, password)
            # self.fingerprintObj.verifyPassword()
        except:
            self.fingerprintObj = False
        
        self.TimerThemVanTay = QTimer()
        self.TimerThemVanTay.timeout.connect(self.ThemVanTay)
        self.TimerLayVanTayDangNhap = QTimer()
        self.TimerLayVanTayDangNhap.timeout.connect(self.ThreadLayVanTayDangNhap)
        self.FlagFGPfree = True
        
    def BatThemVanTay(self):
        if(not self.TimerThemVanTay.isActive()):
            self.TimerThemVanTay.start(1500)
            
    def TatThemVanTay(self):
        if(self.TimerThemVanTay.isActive()):
            self.TimerThemVanTay.stop()
    
    def BatLayVanTayDangNhap(self):
        self.TimerLayVanTayDangNhap.stop()
        self.TimerLayVanTayDangNhap.start(1500)
    
    def TatLayVanTayDangNhap(self):
        if(self.TimerLayVanTayDangNhap.isActive()):
            self.TimerLayVanTayDangNhap.stop()

    def XoaDataBase(self):
        try:
            if(type(self.fingerprintObj) is not bool):
                self.fingerprintObj.clearDatabase()
        except:
            pass

    def ThemVanTay(self):
        try:
            if(type(self.fingerprintObj) is not bool):
                if(self.fingerprintObj.readImage()):
                    self.SignalHandPushed.emit()
                    self.fingerprintObj.convertImage(0x01)
                    self.fingerprintObj.readImage()
                    self.fingerprintObj.convertImage(0x02)
                    if(self.fingerprintObj.compareCharacteristics() > 0):
                        self.fingerprintObj.storeTemplate(1, 0x01)
                        self.SignalNewFGPadded.emit()
                        self.TatThemVanTay()
            else:
                self.SignalNotFGPsensor.emit()
                self.fingerprintObj = PyFingerprint(self.port, self.baudRate, self.address, self.password)
                self.fingerprintObj.verifyPassword()
        except:
            self.SignalNotFGPsensor.emit()
            self.fingerprintObj = False

    
    def ThreadLayVanTayDangNhap(self):
        if(self.FlagFGPfree):
            self.FlagFGPfree = False
            thread = threading.Thread(target = self.LayVanTayDangNhap, args=(), daemon= True)
            thread.start()
    
    def LayVanTayDangNhap(self):
        
        try:
            if(self.fingerprintObj.readImage()):
                self.fingerprintObj.convertImage(0x01)
                ketqua = self.fingerprintObj.searchTemplate()
                if(len(ketqua) == 2):
                    if(ketqua[0] == 1):
                        self.SignalRecognizedFGP.emit()

        except:
            self.SignalNotFGPsensor.emit()
        self.FlagFGPfree = True