def identify(fps, mode, num):
    print 'Place finger on sensor for identification, please'

    #wait for the user to place their finger on the scanner
    while fps.IsPressFinger() == False:
        FPS.delay(1)

    if mode == 0:
        #capture an image and check if it is in the database
        fps.CaptureFinger(False)
        ID = fps.Identify1_N()  #Verify1_1(0)
        #time.sleep(2)

        #print 'ERR %d' % ID
        #if the user exists and the ID# does not exceed 200, welcome. else, enroll
        if ID < 200:
            print 'Welcome, User #%d' % (ID + 1)
        else:
            print 'User not found'
            time.sleep(1)
            enroll(fps)
    elif mode == 1:
        #capture an image and check if it is in the database
        fps.CaptureFinger(False)
        ID = fps.Verify1_1(num)
        #time.sleep(2)
        #print 'ERR %d'% ID
        #if the user exists and the ID# does not exceed 200, welcome. else, enroll
        if ID == 0:
            print 'Welcome, User #%d' % (num + 1)
        else:
            print 'User mismatch, check database for a match'
            time.sleep(1)
            identify(fps, 0, 0)
def DeleteEverything(fps):
    lcd.clear()
    lcd.message("Wiping all Data.")
    FPS.delay(0.5)
    fps.DeleteAll()
    lcd.clear()
    lcd.message("All Users' Data\nDeleted.")
Example #3
0
def LegacyEnroll(fps):
    '''
    Enroll test
    '''
    enrollid = SlotFinder()

    if enrollid < 3000:
        #press finger to Enroll enrollid
        tkMessageBox.showinfo("", "PLACE YOUR FINGER TO ENROLL")
        print 'Press finger to Enroll %s' % str(enrollid)
        fps.EnrollStart(enrollid)
        while not fps.IsPressFinger():
            FPS.delay(3)
        iret = 0
        if fps.CaptureFinger(True):
            #remove finger
            print 'remove finger'
            fps.Enroll1()
            while not fps.IsPressFinger():
                FPS.delay(3)
            #Press same finger again
            print 'Press same finger again'
            while not fps.IsPressFinger():
                FPS.delay(3)
            if fps.CaptureFinger(True):
                #remove finger
                print 'remove finger'
                fps.Enroll2()
                while not fps.IsPressFinger():
                    FPS.delay(3)
                #Press same finger again
                print 'press same finger yet again'
                while not fps.IsPressFinger():
                    FPS.delay(3)
                if fps.CaptureFinger(True):
                    #remove finger
                    iret = fps.Enroll3()
                    if iret == 0:
                        tkMessageBox.showinfo("", "ENROLLING SUCCESSFUL")
                        print 'Enrolling Successfull'
                        addrprivate = RSA.generate(1024)
                        addrpublic = addrprivate.publickey()
                        PrivKey = addrprivate.exportKey()
                        PublKey = addrpublic.exportKey()
                        dBaseSync(enrollid, PrivKey, PublKey)
                    else:
                        tkMessageBox.showinfo("", "ENROLLING FAILED")
                        print 'Enrolling Failed with error code: %s' % str(
                            iret)
                else:
                    print 'Failed to capture third finger'
            else:
                print 'Failed to capture second finger'
        else:
            print 'Failed to capture first finger'
    else:
        print 'Failed: enroll storage is full'
Example #4
0
def fps_init():
    print 'initializing fingerpirnt scanner'
    fps =  FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',baud=9600,timeout=2,is_com=False)
    fps.UseSerialDebug = True
    fps.SetLED(False)
    FPS.delay(1)
    fps.DeleteAll()
    print 'done.'
    return fps
Example #5
0
def Verify(fps,id):
    imgRaw = GetRawImg(fps)
    if imgRaw.__len__()>0:
        FPS.delay(3)
        img = processImage('fingerprint_verify_'+id+'.raw',imgRaw)
        savedImg1 = SavedImg('fingerprint'+id+'.raw')
        return 'Verified is: %s' % (str(matchBif(img, savedImg1)))
    else:
        return 'Not Verified'
Example #6
0
def LegacyEnroll():
    '''
    Enroll test
    '''

    enrollid = 0
    okid = False
    #search for a free enrollid, you have max 200
    while not okid and enrollid < 200:
        okid = fps.CheckEnrolled(enrollid)
        if not okid:
            enrollid += 1
    if enrollid < 200:
        #press finger to Enroll enrollid
        print 'Press finger to Enroll %s' % str(enrollid)
        fps.EnrollStart(enrollid)
        while not fps.IsPressFinger():
            FPS.delay(1)
        iret = 0
        if fps.CaptureFinger(True):
            #remove finger
            print 'remove finger'
            fps.Enroll1()
            while not fps.IsPressFinger():
                FPS.delay(1)
            #Press same finger again
            print 'Press same finger again'
            while not fps.IsPressFinger():
                FPS.delay(1)
            if fps.CaptureFinger(True):
                #remove finger
                print 'remove finger'
                fps.Enroll2()
                while not fps.IsPressFinger():
                    FPS.delay(1)
                #Press same finger again
                print 'press same finger yet again'
                while not fps.IsPressFinger():
                    FPS.delay(1)
                if fps.CaptureFinger(True):
                    #remove finger
                    iret = fps.Enroll3()
                    if iret == 0:
                        print 'Enrolling Successfull'
                    else:
                        print 'Enrolling Failed with error code: %s' % str(
                            iret)
                else:
                    print 'Failed to capture third finger'
            else:
                print 'Failed to capture second finger'
        else:
            print 'Failed to capture first finger'
    else:
        print 'Failed: enroll storage is full'
Example #7
0
def LegacyEnroll(fps):
    '''
    Enroll test
    '''

    enrollid=0
    okid=False
    #search for a free enrollid, you have max 200
    while not okid and enrollid < 200:
        okid = fps.CheckEnrolled(enrollid)
        if not okid:
            enrollid+=1
    if enrollid <200:
        #press finger to Enroll enrollid
        print 'Press finger to Enroll %s' % str(enrollid)
        fps.EnrollStart(enrollid)
        while not fps.IsPressFinger():
            FPS.delay(1)
        iret = 0
        if fps.CaptureFinger(True):
            #remove finger
            print 'remove finger'
            fps.Enroll1()
            while not fps.IsPressFinger():
                FPS.delay(1)
            #Press same finger again
            print 'Press same finger again'
            while not fps.IsPressFinger():
                FPS.delay(1)
            if fps.CaptureFinger(True):
                #remove finger
                print 'remove finger'
                fps.Enroll2()
                while not fps.IsPressFinger():
                    FPS.delay(1)
                #Press same finger again
                print 'press same finger yet again'
                while not fps.IsPressFinger():
                    FPS.delay(1)
                if fps.CaptureFinger(True):
                    #remove finger
                    iret = fps.Enroll3()
                    if iret == 0:
                        print 'Enrolling Successfull'
                    else:
                        print 'Enrolling Failed with error code: %s' % str(iret)
                else:
                    print 'Failed to capture third finger'
            else:
                print 'Failed to capture second finger'
        else:
            print 'Failed to capture first finger'
    else:
        print 'Failed: enroll storage is full'
Example #8
0
def GetRawImg(fps):
    ret = bytes()
    if fps.SetLED(True) and fps.IsPressFinger():
        if fps.GetRawImage():
            response = fps._lastResponse.RawBytes[16:]
            print fps.serializeToSend(response)
            print u'Size %s' % str(response.__len__())
            ret = bytes(response)
    FPS.delay(0.1)
    fps.SetLED(False)
    return ret
Example #9
0
def identify1_n(fps):
    fps.SetLED(True)
    sock.sendall('Press finger\n')
    while not fps.IsPressFinger():
        FPS.delay(0.1)
        print 'Press finger'
    
    if fps.CaptureFinger(True):
        time.sleep(0.1)
        print"remove finger"
        sock.sendall('Remove finger\n')
        id_identify=fps.Identify1_N()
        print "id is",id_identify
        sock.sendall('id is :'+str(id_identify))
    fps.SetLED(True)
Example #10
0
def Verify1_1(fps):
    fps.SetLED(True)
    id=sock.recv(1024)
    id=int(id[0])
    sock.sendall('Press finger\n')
    while not fps.IsPressFinger():
        FPS.delay(0.1)
        print 'Press finger'
    
    if fps.CaptureFinger(True):
        time.sleep(0.1)
        if fps.Verify1_1(id)==0:
            print"yes!!id and fingerprint matched."
            sock.sendall("yes!!id and fingerprint matched.")
        else:
            print"oops!!id and fingerprint not matched."
            sock.sendall("oops!!id and fingerprint not matched.")
    fps.SetLED(True)
Example #11
0
def Loggin(fps):
    '''
    Log in and retrieve ID
    '''
    enrollid = SlotFinder()
    while not fps.IsPressFinger():
        FPS.delay(3)
        iret = 0
    if fps.CaptureFinger(True):
        tkMessageBox.showinfo("", "PLACE YOUR FINGER")
        #remove finger
        print 'remove finger'
        iret = fps.Identify1_N()
        print(iret)
        vs = str(iret)
        idkey = open('/home/pi/python-GT511c3/Session.idk', 'w')
        idkey.write(vs)
        idkey.close()
def Delete(fps):
    lcd.clear()
    lcd.message("Press Finger\nTo Remove")
    while not fps.IsPressFinger():
        FPS.delay(1)
    if fps.CaptureFinger(True):
        lcd.clear()
        lcd.message("Indentifying..")
        UserID = fps.Identify1_N()
    if UserID < 200 and UserID >= 0:
        FPS.delay(1)
        fps.DeleteID(UserID)
        lcd.clear()
        lcd.message("Identity #%s\nRemoved." % str(UserID))
        print "Identity %s Removed." % str(UserID)
    else:
        lcd.clear()
        lcd.message("Fingerprint\nnot found.")
def Verify(fps):
    lcd.clear()
    lcd.message("Press Finger\nTo Verify")
    # Verify Test Function
    ID = -1
    print "Press Finger to Scanner."
    while not fps.IsPressFinger():
        FPS.delay(1)
    if fps.CaptureFinger(True):
        lcd.clear()
        lcd.message("Identifying..")
        FPS.delay(0.5)
        ID = fps.Identify1_N()
        if ID < 200 and ID >= 0:
            print "Welcome, User #%s" % str(ID)
            lcd.clear()
            lcd.message("Welcome,\nUser #%s" % str(ID))
        else:
            lcd.clear()
            lcd.message("Fingerprint\nnot found.")
            print "Fingerprint not found. \n"
Example #14
0
def Finger_PrintSM(msg):
    fps =  FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',baud=9600,timeout=2,is_com=False)
    fps.UseSerialDebug = True
    fps.SetLED(True) # Turns ON the CMOS LED
    FPS.delay(1) # wait 1 second
    print 'Put your finger in the scan'
    
    if not hasattr(Finger_PrintSM,"state"):
        #Declare intial state
        Finger_PrintSM.state = IDLE
        print Finger_PrintSM.state

    print 'CurState:[' + Finger_PrintSM+']'
    print 'Cmd:[' + msg + ']'

    if(Finger_PrintSM.state == IDLE):
       if(msg == 'First'):
          Finger_PrintSM.state = GET_FIRST

    elif(Finger_PrintSM.state == GET_FIRST):
        if(msg == 'Second'):
            Finger_PrintSM.state = GET_SECOND
          
    elif(Finger_PrintSM.state is GET_SECOND):
        if(msg == 'Third'):
            Finger_PrintSM.state = GET_THIRD
        
    elif(Finger_PrintSM.state is GET_THIRD):
        if(msg == 'Finish'):
            Finger_PrintSM.state = STORE_FINGER
        
    elif(Finger_PrintSM.state is STORE_FINGER):
        print 'About to store finger'
        Finger_PrintSM.state = IDLE
    elif(Finger_PrintSM.state is WARNING):
        print 'Warning'
    else:
        print 'unknown state'
def LoopCaptureFinger(scanner):
    while not fps.IsPressFinger():  #verify if the finger is in the scan
        print 'Place your finger on scanner'
        FPS.delay(1)
    print 'Your finger is in the scan'

    print 'Capture Finger'
    fingerFLAG = False
    for i in range(3):
        print 'Keep Finger Pressed'
        if fps.CaptureFinger(False):
            fingerFLAG = True
            print 'Remove Finger'
            while fps.IsPressFinger():
                FPS.delay(1)
            break
        FPS.delay(1)

    if fingerFLAG:
        print 'Finger successfully captured'
    else:
        print 'Finger was not captured'
Step 4: 
Connect the Ground pin of fingerprint GT511C3 to ground pin in GPIO


This may be works fine, if don't, try to change the fingerprint baud rate with baud_to_115200.py sample code


'''
import FPS, sys

if __name__ == '__main__':
    fps =  FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',baud=9600,timeout=2,is_com=False)
    fps.UseSerialDebug = True
    fps.SetLED(True) # Turns ON the CMOS LED
    FPS.delay(1) # wait 1 second
    print 'Put your finger in the scan'
    counter = 0 # simple counter for wait 10 seconds
    while counter < 10:
        if fps.IsPressFinger():  #verify if the finger is in the scan
            print 'Your finger is in the scan'
            fps.SetLED(False) # Turns OFF the CMOS LED
            break
        else:
            FPS.delay(1) #wait 1 second
            counter = counter + 1
    
    fps.Close() # Closes serial connection
    pass

def Enroll(fps):
    lcd.clear()
    lcd.message("Finding open\nID Number.")
    enrollid = 0
    okid = False
    iret = 5
    while not okid and enrollid < 200:
        okid = fps.CheckEnrolled(enrollid)
        if not okid:
            enrollid += 1
    if enrollid < 200:
        lcd.clear()
        lcd.message("Press Finger\nTo Enroll")
        fps.EnrollStart(enrollid)
        while not fps.IsPressFinger():
            FPS.delay(1)
        if fps.CaptureFinger(True):
            lcd.clear()
            lcd.message("Enrolling 1..")
            FPS.delay(0.5)
            iret = fps.Enroll1()
            lcd.clear()
            lcd.message("Remove Finger.")
            while fps.IsPressFinger():
                FPS.delay(1)
            lcd.clear()
            lcd.message("Press same\nfinger again.")
            while not fps.IsPressFinger():
                FPS.delay(1)
            if fps.CaptureFinger(True):
                FPS.delay(0.5)
                lcd.clear()
                lcd.message("Enrolling 2..")
                iret = fps.Enroll2()
                lcd.clear()
                lcd.message("Remove Finger.")
                while fps.IsPressFinger():
                    FPS.delay(1)
                lcd.clear()
                lcd.message("Press same\nfinger again.")
                while not fps.IsPressFinger():
                    FPS.delay(1)
                if fps.CaptureFinger(True):
                    FPS.delay(0.5)
                    lcd.clear()
                    lcd.message("Enrolling 3..")
                    iret = fps.Enroll3()
                    FPS.delay(1)
                    print "----------------------------> iret value: %s" % str(iret)
                    if iret == 0:
                        print "Enrolling Successful"
                        print "Stored as ID #%s" % str(enrollid)
                        lcd.clear()
                        lcd.message("Success!\nID #%s enrolled" % str(enrollid))
                        FPS.delay(3)
                    else:
                        print "Enrolling Failed with error code: %s" % str(iret)
                        FPS.delay(1.5)
                else:
                    print "Failed to capture third finger"
                    print "Enrolling Failed with error code: %s" % str(iret)
                    lcd.clear()
                    lcd.message("Third Capture\nFailed")
                    FPS.delay(3)
            else:
                print "Failed to capture second finger"
                print "Enrolling Failed with error code: %s" % str(iret)
                lcd.clear()
                lcd.message("Second Capture\nFailed")
                FPS.delay(3)
        else:
            print "Failed to capture first finger"
            print "Enrolling Failed with error code: %s" % str(iret)
            lcd.clear()
            lcd.message("First Capture\nFailed")
            FPS.delay(3)
    else:
        print "Failed: enroll storage is full"
        lcd.clear()
        lcd.message("Enroll Failed\nStorage Full")
        FPS.delay(3)
    if iret == 1:
        lcd.clear()
        lcd.message("Enroll Failed")
        FPS.delay(2)
    elif iret == 2:
        lcd.clear()
        lcd.message("Enroll Failed\nBad Finger")
        FPS.delay(2)
    elif iret == 3:
        lcd.clear()
        lcd.message("Enroll Failed\nPrint in Use")
        FPS.delay(2)
    else:
        pass
Example #18
0
def waitUntilRelease(fps):
    while fps.IsPressFinger() == True:
        FPS.delay(FPS.INTERVAL + 0.03)
Example #19
0
def waitUntilPress(fps):
    while fps.IsPressFinger() == False:
        FPS.delay(FPS.INTERVAL + 0.03)
Example #20
0
                          baud=9600,
                          timeout=2,
                          is_com=False)
    fps.UseSerialDebug = False
    GPIO.setmode(
        GPIO.BCM
    )  # programming the GPIO by BOARD pin numbers, GPIO21 is called as PIN21
    # Set the LED GPIO number
    LED = 21

    # Set the LED GPIO pin as an output
    GPIO.setup(LED, GPIO.OUT)  # initialize digital pin21 as an output.
    # fps.UseSerialDebug = True

    #fps.SetLED(True) # Turns ON the CMOS LED
    FPS.delay(1)  # wait 1 second for initialize finish
    fps.SetLED(True)  # Turns ON the CMOS LED

    while True:
        while fps.IsPressFinger() == False:
            FPS.delay(FPS.INTERVAL + 0.03)
            socketIO.on('fps_com', on_fps_com_response)
            socketIO.wait(0.05)
            # print("i'm here",socket_cmd)
            if socket_cmd == 'add':
                # print('add')
                LegacyEnroll(fps)
                FPS.delay(2)  # wait 1 second
                socket_cmd = 'none'
            elif socket_cmd == 'delete':
                print('delete')
Example #21
0
def enroll(fps):
    ID = 0
    count = 0
    unavail = True
    prevcount = fps.GetEnrollCount()
    #increment through IDs in chronological order until one is available
    while unavail == True:
        unavail = fps.CheckEnrolled(ID)
        if (unavail == True):
            ID += 1

    fps.EnrollStart(ID)

    print 'Enrollment takes three scans.'
    print 'Place finger on sensor, please, user # %d' % (ID + 1)

    #wait for finger to be present on device
    while fps.IsPressFinger() == False:
        FPS.delay(1)

    capt = fps.CaptureFinger(False)
    captErr = 0

    #if capture was successful, proceed to enroll1
    if capt == True:
        print 'Please remove finger'
        captErr = fps.Enroll1()
        #print 'Err Status: %d' % captErr
        captErr = 0

        #wait for finger to be removed from device
        while fps.IsPressFinger() == True:
            FPS.delay(1)

        print 'Place the same finger a second time'

        #wait for finger to be present again
        while fps.IsPressFinger() == False:
            FPS.delay(1)

        capt = fps.CaptureFinger(False)

        if capt == True:
            print 'Please remove finger'
            captErr = fps.Enroll2()
            #print 'Err Status: %d' % captErr
            captErr = 0

            while fps.IsPressFinger() == True:
                FPS.delay(1)

            print 'Place the same finger a third time'

            while fps.IsPressFinger() == False:
                FPS.delay(1)

            capt = fps.CaptureFinger(False)

            if capt == True:
                print 'Please remove finger'
                captErr = fps.Enroll3()
                #print 'Err Status: %d' % captErr
                currcount = fps.GetEnrollCount()
                if captErr == 0:
                    if currcount != prevcount:
                        print 'You have successfully been enrolled'
                    else:
                        print 'Enrollment unsuccessful. Error code: 2'
                else:
                    print 'Enrollment unsuccessful. Error code: %d' % captErr
                    #enroll(fps)
            else:
                print 'Enrollment unsuccessful, did not capture third finger.'
        else:
            print 'Enrollment unsuccessful, did not capture second finger.'
    else:
        print 'Enrollment unsuccessful, did not capture first finger.'
def main():
    fps = FPS.FPS_GT511C3(
        device_name="/dev/ttyAMA0", baud=9600, timeout=2, is_com=False
    )  # settings for raspberry pi GPIO
    fps.Open()
    kp = keypad()
    digit = None

    # Loop while waiting for a keypress
    WelcomeMessage()

    digit = kp.getKey()

    if digit == 1:
        if fps.SetLED(True):
            Verify(fps)
        FPS.delay(2)
    elif digit == 2:
        if fps.SetLED(True):
            Enroll(fps)
        FPS.delay(2)
    elif digit == 3:
        if fps.SetLED(True):
            Delete(fps)
        FPS.delay(2)
    elif digit == 4:
        UserStats(fps)
    elif digit == 0:
        lcd.clear()
        lcd.message("Don't just\npress buttons.")
        FPS.delay(0.5)
        digit = kp.getKey()
        if digit == 8:
            lcd.clear()
            lcd.message("Seriously, stop\ndoing that.")
            FPS.delay(0.5)
            digit = kp.getKey()
            if digit == 5:
                lcd.clear()
                lcd.message("I'm Serious! Not\none more button!")
                FPS.delay(0.5)
                digit = kp.getKey()
                if digit == 2:
                    lcd.clear()
                    lcd.message("NO! That button\ndeletes all the-")
                    time.sleep(2)
                    DeleteEverything(fps)
        elif digit == 0:
            lcd.clear()
            lcd.message("~~~~~~~~~~~~~~~~")
            FPS.delay(0.5)
            digit = kp.getKey()
            if digit == 0:
                lcd.clear()
                lcd.message("\n~~~~~~~~~~~~~~~~")
                FPS.delay(0.5)
                digit = kp.getKey()
                if digit == 0:
                    lcd.clear()
                    lcd.message("POWER OPTIONS\nOFF=1 | RSET=2")
                    FPS.delay(0.5)
                    digit = kp.getKey()
                    POWERFUNC(digit)
    else:
        lcd.clear()
        lcd.message("Invalid Input\nTry Again")
        time.sleep(1.5)

    print digit
    # return digit
    fps.SetLED(False)
    FPS.delay(1)
    fps.Close()
Example #23
0
    else:
        print 'Failed: enroll storage is full'
        # msg = 'Failed: enroll storage is full'
        # socketIO.emit('fps_com', msg)


if __name__ == '__main__':
    fps = FPS.FPS_GT511C3(device_name=DEVICE_GPIO,
                          baud=9600,
                          timeout=2,
                          is_com=False)
    fps.UseSerialDebug = False
    # fps.UseSerialDebug = True

    fps.SetLED(False)  # Turns ON the CMOS LED
    FPS.delay(5)  # wait 1 second for initialize finish

    # socketIO = SocketIO('http://192.168.1.37', 8080, verify=False)
    # socketIO.on('connect', on_connect)
    # socketIO.on('fps_com', on_fps_com_response)
    # socketIO.emit('fps_com', 'FPS >>> standby')
    # socketIO.wait(0.5)
    # while True:
    #     waitUntilPress(fps)
    #     idenid = identifyprotocol(fps)
    #     print 'lift the finger'
    #     socketIO.on('fps_com', on_fps_com_response)
    #     socketIO.emit('fps_com', idenid)
    #     socketIO.wait(0.5)
    #     fps.SetLED(False) # Turns OFF the CMOS LED
    #     FPS.delay(0.1) # wait 1 second for initialize finish
Example #24
0
def Enroll(fps,id):
    imgRaw = GetRawImg(fps)
    if imgRaw.__len__()>0:
        FPS.delay(3)
        SaveImage('fingerprint'+id+'.raw', imgRaw)
    """
Example #25
0
def enroll_ID(fileID,ldev):
##    if queue.returnscannerID(fileID) == -1:
##        print 'already exists'
##        return
    ctime = 0
    ID=0;count=0
    unavail=True
    prevcount=fps.GetEnrollCount()
    #increment through IDs in chronological order until one is available
    while unavail==True:
       unavail=fps.CheckEnrolled(ID)
       if(unavail==True):
           ID+=1

    fps.EnrollStart(ID)

    
    #wait for finger to be present on device
    FPS.delay(1)
    print 'Enrollment takes three scans.'
    print 'Place finger on sensor, please, user # %d' % (ID+1)
    USB.writebuf(ldev,'$FPENROLL,EN1')
    fps.SetLED(True)
    ctime = time.time()
    if fps.IsPressFinger():
        FPS.delay(.5)
    while fps.IsPressFinger()==False:
        newtime = time.time()-ctime
        FPS.delay(.5)
        if (newtime) > 5.0:
            print '5 seconds'
            USB.writebuf(ldev,'$FPENROLL,EN1,TIMEOUT')
            fps.SetLED(False)
            return

    capt=fps.CaptureFinger(True)
    captErr=0

    #if capture was successful, proceed to enroll1
    if capt==True:
        print 'Please remove finger'
        USB.writebuf(ldev,'$FPENROLL,RM1')
        captErr=fps.Enroll1()
        #print 'Err Status: %d' % captErr
        captErr=0

        #wait for finger to be removed from device
        while fps.IsPressFinger()==True:
            FPS.delay(1)

        print 'Place the same finger a second time'
        USB.writebuf(ldev,'$FPENROLL,EN2')
        #wait for finger to be present again
        ctime = time.time()
        while fps.IsPressFinger()==False:
            newtime = time.time()-ctime
            FPS.delay(.5)
            if (newtime) > 5.0:
                print '5 seconds'
                USB.writebuf(ldev,'$FPENROLL,EN2,TIMEOUT')
                fps.SetLED(False)
                return

        capt=fps.CaptureFinger(True)

        if capt==True:
            print 'Please remove finger'
            USB.writebuf(ldev,'$FPENROLL,RM2')
            captErr=fps.Enroll2()
            #print 'Err Status: %d' % captErr
            captErr=0

            while fps.IsPressFinger()==True:
                FPS.delay(1)

            print 'Place the same finger a third time'
            USB.writebuf(ldev,'$FPENROLL,EN3')
            ctime = time.time()
            while fps.IsPressFinger()==False:
                newtime = time.time()-ctime
                FPS.delay(1)
                if (newtime) > 5.0:
                    print '5 seconds'
                    USB.writebuf(ldev,'$FPENROLL,EN3,TIMEOUT')
                    fps.SetLED(False)
                    return

            capt=fps.CaptureFinger(True)

            if capt==True:
                print 'Please remove finger'
                USB.writebuf(ldev,'$FPENROLL,RM3')
                captErr=fps.Enroll3()
                #print 'Err Status: %d' % captErr
                currcount=fps.GetEnrollCount()
                if captErr==0:
                    if currcount!=prevcount:
                        print 'You have successfully been enrolled'
                        #queue.assign_scannerID(fileID, currcount)
                        save_template(fileID, ID)
                        if queue.assign_scannerID(fileID,ID) == -1:
                            fps.DeleteID(ID)
                            stng = ',NOTINQ'
                        else:
                            stng = ',ADDEDTOQ'
                        fps.SetLED(False)
                        return '$FPENROLL,SUCC,' + str(fileID) + stng
                    else:
                        print 'Enrollment unsuccessful. Error code: 2'
                        fps.SetLED(False)
                        return '$FPENROLL,ERR,2'
                else:
                    print 'Enrollment unsuccessful. Error code: %d' % captErr
                    #enroll(fps)
                    fps.SetLED(False)
                    return '$FPENROLL,ERR.' + str(captErr)
            else:
                print 'Enrollment unsuccessful, did not capture third finger.'
                fps.SetLED(False)
                return '$FPENROLL,ERR,3'
        else:
            print 'Enrollment unsuccessful, did not capture second finger.'
            fps.SetLED(False)
            return '$FPENROLL,ERR,2'
    else:
        print 'Enrollment unsuccessful, did not capture first finger.'
        fps.SetLED(False)
        return '$FPENROLL,ERR,1'
Example #26
0
def Enroll(fps):
    '''
    Enroll test
    '''
    fps.SetLED(True)
    enrollid=0
    okid=True
    #search for a free enrollid, you have max 200
    message="wait until the id no. is allotted\n"
    sock.sendall(message)
    while okid and enrollid < 200:
        okid = fps.CheckEnrolled(enrollid)
        print"alloting id no."
        if okid:
            enrollid+=1
            
            #print enrollid,okid
            #print 'this is the enroll id'
    if enrollid <200:
        #press finger to Enroll enrollid
        print 'Press finger to Enroll for first capture %s' % str(enrollid)
        message1="id. allocated is "+str(enrollid)+"\nPress finger to start enrollment\n"
        sock.sendall(message1)
        time.sleep(0.2)
        fps.EnrollStart(enrollid)
        while not fps.IsPressFinger():
            print'Press finger'
            sock.send("press finger\n")
            FPS.delay(0.2)
        iret = 0
        if fps.CaptureFinger(True):
            time.sleep(0.2)
            #remove finger
            print 'remove finger'
            sock.sendall("remove finger\n")
               
            fps.Enroll1()
            fps.SetLED(False)
            time.sleep(0.2)
            #print 'Enrollment 1 successfull'
            fps.SetLED(True)
            while not fps.IsPressFinger():
                FPS.delay(0.2)
            #Press same finger again
            print 'Press same finger again'
            sock.sendall("press same finger again\n")
            while not fps.IsPressFinger():
                FPS.delay(0.1)
            if fps.CaptureFinger(True):
                #remove finger
                time.sleep(0.1)
                print 'remove finger'
                sock.sendall('remove finger\n')
                fps.Enroll2()
                fps.SetLED(False)
                time.sleep(0.1)
                #print 'Enrollment 2 successfull'
                fps.SetLED(True)
                while not fps.IsPressFinger():
                    FPS.delay(0.1)
                #Press same finger again
                print 'press same finger yet again'
                sock.sendall('press same finger yet again\n')
                while not fps.IsPressFinger():
                    FPS.delay(0.1)
                if fps.CaptureFinger(True):
                    #remove finger
                    iret = fps.Enroll3()
                    time.sleep(0.1)
                    fps.SetLED(False)
                    #print 'Enrollment successfull'
                    if iret == 0:
                        print 'Enrolling Successfull'
                        sock.sendall('Enrolling Successful\n')
                    else:
                        print 'Enrolling Failed with error code: %s' % str(iret)
                        sock.sendall('Enrolling Failed with error code:'+str(iret)+'\n')
                else:
                    print 'Failed to capture third finger'
                    sock.sendall('Failed to capture third finger\n')
            else:
                print 'Failed to capture second finger'
                sock.sendall('Failed to capture second finger\n')
        else:
            print 'Failed to capture first finger'
            sock.sendall('Failed to capture first finger\n')
    else:
        print 'Failed: enroll storage is full'
        sock.sendall('Failed: enroll storage is full\n')
Example #27
0
        if ID == 0:
            print 'Welcome, User #%d' % (num + 1)
        else:
            print 'User mismatch, check database for a match'
            time.sleep(1)
            identify(fps, 0, 0)


if __name__ == '__main__':
    fps = FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',
                          baud=9600,
                          timeout=2,
                          is_com=False)
    fps.UseSerialDebug = True
    fps.SetLED(True)  # Turns ON the CMOS LED
    FPS.delay(2)  # wait 1 second
    #fps.DeleteAll()
    #fps.DeleteID(5)
    #enroll(fps)
    identify(fps, 1, 0)
    enrollcount = fps.GetEnrollCount()
    print 'Enroll count: %d' % enrollcount

    ##    print 'Put your finger in the scan'
    ##    counter = 0 # simple counter for wait 10 seconds
    ##    while counter < 10:
    ##        if fps.IsPressFinger():  #verify if the finger is in the scan
    ##            print 'Your finger is in the scan'
    ##            fps.SetLED(False) # Turns OFF the CMOS LED
    ##            break
    ##        else: